我試圖在Twitter Android應用中模仿一個動作。當你長按/滑動鳴叫(列表項),它看起來像這樣如何在長按列表項時加載列表視圖中的菜單
這很容易讓用戶採取的列表項的操作,而無需離開屏幕。我如何在我的應用中做類似的事情?
現在我已經添加了一個上下文菜單,看起來像這樣(注意,它淡出了應用程序的其餘部分)。
我通過registerForContextMenu(listView)
目前實現這一點,我的名單是這樣的:
ListAdapter adapter = new SimpleAdapter(
MainActivity.this, myList,
R.layout.list_items, new String[] {LI_ID,
LI_NAME, LI_COUNT}, new int[] {
R.id.li_id, R.id.li_name, R.id.li_count});
setListAdapter(adapter);
和我的佈局僅僅是這樣的:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/li_id"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="gone" />
<TextView
android:id="@+id/li_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="16dip"
android:textColor="#000000"
android:paddingTop="15dip"
android:paddingBottom="15dip"
android:paddingLeft="10dip"
android:textStyle="bold"/>
<TextView android:id="@+id/li_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:textColor="#ffffff"
android:textStyle="bold"
android:background="#9ed321"
android:paddingRight="3dip"
android:paddingLeft="3dip"/>
</RelativeLayout>
那整齊。但我不是在那之後。 – Anthony