我想创建一个自定义多选列表视图,任何人都可以帮忙。
在我的情况下,我有一个带有四个文本视图和一个复选框的自定义布局。
这是我的代码
https://stackoverflow.com/a/10561814/1381622
这是我的代码
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.take_order);
addToOrder=(Button)findViewById(R.id.addToOrder);
order=(Button)findViewById(R.id.order);
back=(ImageButton)findViewById(R.id.back);
buttonSeperator=(ImageView)findViewById(R.id.buttonSeperator);
spTable=(Spinner)findViewById(R.id.tableNo);
ArrayAdapter<CharSequence> adapter=ArrayAdapter.createFromResource(this,R.array.tableList,android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_item);
spTable.setAdapter(adapter);
spTable.setOnItemSelectedListener(this);
categoryList=(ListView)findViewById(R.id.foodCategoryList);
//categoryList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
//categoryList.setItemsCanFocus(false);
fc=new FoodCategory();
categoryAdapter=fc.new FoodAdapter(this,R.layout.food_category_list,fc.list);
categoryList.setAdapter(categoryAdapter);
categoryList.setOnItemClickListener(this);
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
fl=new FoodList();
order.setVisibility(View.GONE);
addToOrder.setVisibility(View.VISIBLE);
back.setVisibility(View.VISIBLE);
buttonSeperator.setVisibility(View.VISIBLE);
fl.bundleCategory=fc.list[position];
fl.foodListService();
WaiterFoodAdapter foodAdapter=new WaiterFoodAdapter(this, R.layout.take_order_list, fl.foodList);
categoryList.setAdapter(foodAdapter);
categoryList.setOnItemClickListener(this);
}
实际上我正在使用一个列表视图,当用户点击列表视图时,我在同一个列表视图中设置另一个适配器... 和
public void back(View v)
{
addToOrder.setVisibility(View.GONE);
back.setVisibility(View.GONE);
buttonSeperator.setVisibility(View.GONE);
order.setVisibility(View.VISIBLE);
categoryList.setAdapter(categoryAdapter);
}
当用户点击后退按钮我再次设置旧适配器,,,,第二个适配器listview无法点击我不知道为什么??
答案 0 :(得分:1)