我想刷新我的ListView
項目,其中項目來自服務器。我使用notifyDataSetChanged();
,但它不適用於我的代碼。我需要當我按下button
ListView
應刷新。我想刷新我的ListView項目,其中項目是動態的
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = context.getLayoutInflater();
View listViewItem = inflater.inflate(R.layout.declined_list_view_layout, null, true);
notifyDataSetChanged();
TextView textViewId = (TextView) listViewItem.findViewById(R.id.textViewId);
TextView textViewName = (TextView) listViewItem.findViewById(R.id.textViewName);
textViewId.setText(ids[position]);
textViewName.setText(ages[position]+" years"+" , "+heights[position]+" cm"+", "+communities[position]+" : "+castes[position]+" , "+educations[position]+" , "+occupations[position]+" , "+incomes[position]+", "+locations[position]);
Button btnSort =(Button) listViewItem.findViewById(R.id.btnshort);
btnSort.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getContext(),"shortlist",Toast.LENGTH_LONG).show();
}
});
Button btnChat =(Button) listViewItem.findViewById(R.id.btnchat);
btnChat.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(v.getContext(), BlankActivity.class);
Toast.makeText(getContext(), ids[position],
Toast.LENGTH_LONG).show();
i.putExtra("id", ids[position]);
v.getContext().startActivity(i);
}
});
return listViewItem;
}
add notifyDataSetChanged()你在哪裏得到數據表服務器 – Anil