我不太清楚我的问题真的有事情做与listview
。有一个名为Gleeo Time Tracker一个应用程序,并here有它。当的屏幕视图按符号"+"
,新项目将被创建,并且您可以通过按"-"
删除一个项目。更多的是,当我单击项目左侧的记录按钮时,背景将会改变。添加新项到ListView
我的问题是,它到底是什么,一个列表视图?我怎样才能做到这一点?谢谢大家!
我不太清楚我的问题真的有事情做与listview
。有一个名为Gleeo Time Tracker一个应用程序,并here有它。当的屏幕视图按符号"+"
,新项目将被创建,并且您可以通过按"-"
删除一个项目。更多的是,当我单击项目左侧的记录按钮时,背景将会改变。添加新项到ListView
我的问题是,它到底是什么,一个列表视图?我怎样才能做到这一点?谢谢大家!
你想做什么,是建立一个自定义的ListView。 这是通过提供一个布局文件来完成,例如
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/transparent">
<ImageView android:id="@+id/Plus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent" />
<TextView android:id="@+id/Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent" />
</LinearLayout>
那么这种布局应用到你的ListView的每一行通过覆盖它的适配器的getView()方法,例如像这样:
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater vi = (LayoutInflater) MyActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.row, null);
}
ImageView plus = (ImageView) v.findViewById(R.id.plus);
icon.setImageDrawable(BrowseActivity.this.getResources().getDrawable(R.drawable.plus));
TextView title = (TextView) v.findViewById (R.id.Browse_FileName);
// add a listener to your button and you're done
return v;
}
阅读有关开发人员文档中的列表视图,这里是example