gpt4 book ai didi

android - 不显示 ListAdapter 值

转载 作者:行者123 更新时间:2023-11-30 02:09:12 25 4
gpt4 key购买 nike

我需要在 ListView 中显示我的值,我需要在 ListView 中单独对特定的 TextView 执行单击

我试过这样

ListAdapter adapter = new SimpleAdapter(
ViewAppoinmentScreen.this, medicationlist,
R.layout.appoinmentlist, new String[] {
"clinic_name", "id", "app_type",
"app_date", "app_time", "app_desc" },
new int[] { R.id.name, R.id.app_id,
R.id.app_type, R.id.date, R.id.time,
R.id.comments }){

@Override
public View getView (int position, View convertView, ViewGroup parent) {
LayoutInflater mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = mInflater.inflate(
R.layout.appoinmentlist, parent, false);
ImageView del = (ImageView) rowView
.findViewById(R.id.imageView3);
del.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
String id = ((TextView) findViewById(R.id.app_id))
.getText().toString();
Toast.makeText(ViewAppoinmentScreen.this, " Clicked Successfully", Toast.LENGTH_LONG).show();
System.out.println("deleted action"+id);


}
});

return rowView;
}

};

med_list.setAdapter(adapter);

Getview 方法正在运行我可以看到 toast 消息,但我无法在我的 ListView 中看到值。值未设置为适配器。我不知道我犯了什么错误?请帮助我。

提前致谢。

最佳答案

我已经通过用这样的东西替换 getView 解决了我的问题

@Override
public View getView (int position, View convertView, ViewGroup parent)
{
View v = super.getView(position, convertView, parent);

ImageView del = (ImageView) v
.findViewById(R.id.imageView3);
del.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Toast.makeText(ViewAppoinmentScreen.this,"Deleted",Toast.LENGTH_SHORT).show();
}
});
return v;
}

现在好了。

关于android - 不显示 ListAdapter 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30348584/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com