开发者

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜