【发布时间】:2015-04-01 18:54:36
【问题描述】:
经过几个小时的搜索,我找不到与我有类似问题的人,请您支持我解决这个问题。
我有一个包含两个listview 的活动:listview1 放在listview2 上方。
我现在需要做的是,每当用户触摸列表视图上的某个项目时,该项目将从当前列表视图中删除,并将显示在另一个列表视图上。
这是我的活动:
private ListView mListApplication_kid, mListApplication_non_kid;
private List<ResolveInfo> mListAplicationInfo;
private List<MyApplication> mListApplicationList = new ArrayList<MyApplication>();
private List<MyApplication> mListApplicationList_non_kid = new ArrayList<MyApplication>();
private KidModeAdapter1 mAplicationAdapter;
private KidModeAdapter2 mAplicationAdapter_non_default;
private Context mContext;
private String TAG = "KidModeActivity";
@Override
protected void onCreate(Bundle arg0) {
// TODO Auto-generated method stub
super.onCreate(arg0);
setContentView(R.layout.activity_kid_mode);
mContext=this;
list_kid_mode = new ArrayList<String>(Arrays.asList(PHONE, CONTACTS, MESSAGE, CAMERA, CHROME));
mListApplication_kid = (ListView) findViewById(R.id.listview_kidmode_default);
mListApplication_non_kid = (ListView) findViewById(R.id.listview_kidmode_non_default);
loadAplication();
}
private void loadAplication() {
mAplicationAdapter = new KidModeAdapter1(mContext, R.layout.aplication_item, mListApplicationList);
mAplicationAdapter_non_default = new KidModeAdapter2(mContext, R.layout.aplication_item, mListApplicationList_non_kid);
mListApplicationList.removeAll(mListApplicationList);
mListApplicationList_non_kid.removeAll(mListApplicationList_non_kid);
mAplicationAdapter.notifyDataSetChanged();
mAplicationAdapter_non_default.notifyDataSetChanged();
new loadKidMode().execute(); // load all the available MyApplication into the mListApplicationList, and mListApplicationList_non_kid
mListApplication_kid.setAdapter(mAplicationAdapter);
mListApplication_non_kid.setAdapter(mAplicationAdapter_non_default);
}
这是我的 xml 文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/txtKidMode"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="5dp"
android:gravity="center"
android:text="@string/default_mode"
android:textColor="@color/title"
android:textSize="@dimen/title_textsize" />
<ListView
android:id="@+id/listview_kidmode_default"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/counter_text_color"
android:clickable="true">
</ListView>
<ListView
android:id="@+id/listview_kidmode_non_default"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:background="@color/list_background"
android:clickable="true">
</ListView>
</LinearLayout>
我知道这是关于此活动和设置 KidModeAdapter1 和 KidModeAdapter2 文件的,但不知道如何。 请你帮帮我好吗!!!
【问题讨论】:
标签: android listview android-listview