listview = (ListView) findViewById(R.id.listView3);
// Array holding our data
String[] allproduct = {"TV", "Mobile", "Laptop", "KichenWare", "Apple Iphone", "Samsung S6"};
//adapter which will convert each data item into view item.
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.allproductslist, R.id.textView12, allproduct);
//place each view-item inside listview by setting adapter for our listview
listview.setAdapter(adapter);
// Register the ListView for Context menu
registerForContextMenu(listview);
}
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo)
{
super.onCreateContextMenu(menu, v, menuInfo);
menu.setHeaderTitle("Select The Action");
menu.add(0, v.getId(), 0, "Edit");//groupId, itemId, order, title
menu.add(0, v.getId(), 0, "Remove");
}
@Override
public boolean onContextItemSelected(MenuItem item){
if(item.getTitle()=="Edit"){
Toast.makeText(getApplicationContext(),"No Data Available",Toast.LENGTH_LONG).show();
}
else if(item.getTitle()=="Remove"){
Toast.makeText(getApplicationContext(),"No Access", Toast.LENGTH_LONG).show();
}else{
return false;
}
return true;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
1.
这是我的活动 2.此处当用户选择任何一个产品时,它将弹出“编辑”和“删除”操作。 3.选择编辑按钮时,将显示“无可用数据”。 4.但我的要求是它应该重定向到另一个允许应用过滤器的屏幕(编辑用户选择页面) 在这里,我包括我到目前为止所做的事情。 6.任何帮助都要感谢他们。
. If the user selects any check box and save the choice.
<?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"
android:weightSum="1">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="30dp">
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="30dp">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/scrollView"
android:scrollIndicators="top|bottom"
android:nestedScrollingEnabled="true"
android:layout_gravity="top">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="200dp"
android:weightSum="1">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="You Are Looking For..."
android:id="@+id/textView10"
android:layout_gravity="center_horizontal"
android:textSize="30dp"
android:textStyle="bold" />
<EditText
android:layout_width="338dp"
android:layout_height="wrap_content"
android:id="@+id/editText"
android:layout_gravity="center_horizontal"
android:autoText="true"
android:paddingTop="20dp"
android:hint="Product" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="500dp"
android:paddingTop="20dp"
android:weightSum="1"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:layout_weight="2.05">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Filters"
android:id="@+id/textView4"
android:layout_gravity="center_horizontal"
android:textSize="20sp"
android:textStyle="bold" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:paddingTop="10dp"
android:baselineAligned="false">
<ListView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:id="@+id/listView"
android:layout_weight="1" />
<ListView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/lv5"
android:layout_weight="0.7" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="1">
<Button
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Apply"
android:id="@+id/button3"
android:background="#88b9f8"
android:layout_gravity="bottom"
android:gravity="center"
android:layout_alignParentTop="true" />
</LinearLayout>
</LinearLayout>
答案 0 :(得分:0)
您可以使用:
<AutoCompleteTextView
android:id="@+id/autoCompleteTextView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:text="AutoCompleteTextView" >
<requestFocus />
</AutoCompleteTextView>
答案 1 :(得分:0)
@Override
public boolean onContextItemSelected(MenuItem item){
if(item.getTitle()=="Edit"){
Intent intent = new Intent(CurrentActivityName.this,ActivityYouWantToCall.class);
startActivity(intent);
}
else if(item.getTitle()=="Remove"){
Toast.makeText(getApplicationContext(),"No Access", Toast.LENGTH_LONG).show();
}else{
return false;
}
return true;
}