When you use a custom view in aListViewyou must define the row layout. You create an xml where you place android widgets and then in the adapter's code you have to do something like this:

public MyAdapter(Context context, List<MyObject> objects) { super(context, 1, objects); /* We get the inflator in the constructor */ mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } @Override public View getView(int position, View convertView, ViewGroup parent) { View view; /* We inflate the xml which gives us a view */ view = mInflater.inflate(R.layout.my_list_custom_row, parent, false); /* Get the item in the adapter */ MyObject myObject = getItem(position); /* Get the widget with id name which is defined in the xml of the row */ TextView name = (TextView) view.findViewById(R.id.name); /* Populate the row's xml with info from the item */ name.setText(myObject.getName());

}

更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. Android(安卓)EditText属性
  2. Android(安卓)资源文件中@、@android:typ
  3. android:launchMode="singleTask" intent
  4. android EditText输入限制
  5. TextView(标签控件)
  6. Android(安卓)TextView行间距解析
  7. Android系统自带样式(android:theme)
  8. Android(安卓)SDK下载和更新失败的解决方
  9. Linearlayout和relativeLayout的属性的一
  10. Android(安卓)layout_margin 无效的解决