how to take the first element of an arrayList and view in a textview
ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
wordsList.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_开发者_StackOverflow1,
matches));
I want to change this code. I want to take the first element of the wordList and show in a text view
try this not sure it perfect or not but try it
String text = ((TextView)(wordsList.getItemAtPosition(0))).getText();
yourTextView.setText(text);
or you can get the direct value from the ArrayList
String text = matches.get(0).toString();
yourTextView.setText(text);
TextView mTextView=new TextView(mContext);
mTextView.setText(matches.get(0).toString()); // Take first element
myLayout.addView(mTextView);
精彩评论