编辑(求助)对于答案,请转到问题的底部.
我有一个listview,并使用customadapter在其中填充一些行.被充气的行包含一个复选框.我可以保持复选框的状态,但问题是,我的列表项不再可点击.这是我的代码:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
fl=(ListView)findViewById(R.id.MainMenu);//Mainmenu is listview
fl.setAdapter(new CustomAdapter(Annotate.this,R.layout.preann2,_dir));//preann2 is row and _dir is the list of objects
//fl.setOnItemClickListener(this); tried this too
}
public void onItemClick(AdapterView<?> a, View view, int pos, long id)
{
//Implementations
}
public class CustomAdapter extends ArrayAdapter<String>
{
public CustomAdapter(Context context, int textViewResourceId,String[] objects) {
super(context, textViewResourceId,objects);
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
LayoutInflater inflater=getLayoutInflater();
View row=inflater.inflate(R.layout.preann2, parent, false);
try
{
TextView Name=(TextView)row.findViewById(R.id.title);
Name.setText("xyz"); …Run Code Online (Sandbox Code Playgroud) checkbox android listview android-listview onitemclicklistener