I'm trying to mimic an action in the Twitter android app. When you long press/swipe a tweet (list item) it looks like this
This makes it easy for the user to take actions on the list item without leaving the screen. How can I do something similar in my app?
For now I've added a context menu which looks like this (notice that it fades out rest of the app).
I achieved this by registerForContextMenu(listView)
Currently, my list is like this:
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);
and my layout is simply like this:
<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>