Android - Multiple textviews in Listview

I am populating a Listview (list.xml) with a textview (list_row.xml). I need to add an additional textview to list_row.xml, which means I need to wrap them in a layout. However, I get a Textview ID error when I do this. list_row.xml I need: Main.xml public View GetView(int inPosition, View inConvertView, ViewGroup inParent) { View _row = inConvertView; if (_row == null) { // Inflate Row Log.d(TAG, "Starting XML Row Inflation ... "); LayoutInflater inflater = (LayoutInflater) cContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); _row = inflater.inflate(R.layout.list_row, inParent, false); Log.d(TAG, "Successfully completed XML Row Inflation!"); } // Get item PropertiesAd _adProperty = GetItem(inPosition); // Get reference to TextView - country_name cAdName = (TextView) _row.findViewById(R.id.nameTV); //Set name cAdName.setText(_adProperty.toString()); return _row; } For the sake of testing, I haven't added the second textview yet. I'm just trying to get this to work with the layout wrapper. Everything works fine without the LinearLayout. But again, I will need it to add a second textview. Suggestions? Thanks ArrayAdapter: public class ArrayAdapterAd extends ArrayAdapter { private static final String TAG = "AdArrayAdapter"; private Context cContext; private TextView cAdName; private List cAdList = new ArrayList(); public ArrayAdapterAd(Context inContext, int inTextViewResourceId, List inObjects) { super(inContext, inTextViewResourceId, inObjects); this.cContext = inContext; this.cAdList = inObjects; } public int GetCount() { return this.cAdList.size(); } public PropertiesAd GetItem(int inIndex) { return this.cAdList.get(inIndex); } public View GetView(int inPosition, View inConvertView, ViewGroup inParent) { View _row = inConvertView; if (_row == null) { // Inflate Row Log.d(TAG, "Starting XML Row Inflation ... "); LayoutInflater inflater = (LayoutInflater) cContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); _row = inflater.inflate(R.layout.ad_list, inParent, false); Log.d(TAG, "Successfully completed XML Row Inflation!"); } // Get item PropertiesAd _adProperty = GetItem(inPosition); // Get reference to TextView - country_name cAdName = (TextView) _row.findViewById(R.id.ad_listTextView); //Set country name cAdName.setText(_adProperty.toString()); return _row; } }
"I get a Textview ID error" what does it mean? Do you get an exception or something? Or the problem is while compiling? Please elaborate.

以上就是Android - Multiple textviews in Listview的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏