我有自定義列表查看我預覽從服務器獲取的數據。 現在我想改變其itemclick列表視圖中的數據。我想要預覽的新數據也來自服務器。 這是我的BaseAdapter類更改自定義listView Android onclick的內容?
class MyCustomAdapter extends BaseAdapter {
Vector<String> data_text;
int[] data_image;
MyCustomAdapter()
{
data_text = null;
data_image = null;
}
MyCustomAdapter(Vector<String> text, int[] image)
{
data_text = text;
data_image = image;
}
public int getCount()
{
return data_text.size();
}
public String getItem(int position)
{
return null;
}
public long getItemId(int position)
{
return position;
}
public void updateResults(Vector<String> results) {
data_text= results;
//Triggers the list update
notifyDataSetChanged();
}
public View getView(int position, View convertView, ViewGroup parent)
{
LayoutInflater inflater = getLayoutInflater();
View row;
row = inflater.inflate(R.layout.category_list_element, parent, false);
TextView textview = (TextView) row.findViewById(R.id.TextView01);
ImageView imageview = (ImageView) row.findViewById(R.id.ImageView01);
textview.setText(data_text.get(position).toString());
imageview.setImageResource(data_image[position]);
return (row);
}}
請提供解決方案。
請注意我想在onview的列表視圖上預覽同一活動的數據。
,這是我的onclick L1是列表視圖
l1.setAdapter(new MyCustomAdapter(appCat, image));
l1.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,int position,long id)
{
View curr = parent.getChildAt((int) id);
TextView c = (TextView)curr.findViewById(R.id.TextView01);
String sel_item = c.getText().toString();
API_GOD(URL);
}});
API_GOD(URL)是服務器端的數據是收到。 現在告訴我如何更新列表。
API_GOD(URL)的郵政編碼;方法..您需要在完成API_GOD(URL)後調用notifydatasetchanged(); – NaserShaikh