0
이 라이브러리를 사용하고 있습니다 : https://github.com/erikwt/PullToRefresh-ListViewListView를 새로 고침하면 첫 번째 항목 만 클릭 할 수 있습니다. 이유가 무엇입니까?
내 맞춤 어댑터로 PullToRefresh-ListView를 구현합니다.
내 문제는 다음입니다 : 다음은 결과 난 단지 첫 번째 항목 (제목 1, 설명 1)을 클릭하면, 다른 사람이 작동하지 않습니다. 여기에 onClickItem 내 코드는 다음과 같습니다
여기 myAdapter = new ListToRefreshAdapter(this, R.layout.list_item, myItemList);
myList = (PullToRefreshListView) findViewById(R.id.refreshList);
myList.setAdapter(myAdapter);
myList.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// TODO Auto-generated method stub
Context context = view.getContext();
TextView title = (TextView) view.findViewById(R.id.titleItem);
TextView desc = (TextView) view.findViewById(R.id.descItem);
String titleItem = title.getText().toString();
String descItem = desc.getText().toString();
Toast.makeText(context, "Item Title: " + titleItem + ", Item Desc: " + descItem, Toast.LENGTH_SHORT).show();
Log.i("TOUCH EVENT TEST", "OK");
startActivity(new Intent(getApplicationContext(), ItemDetails.class));
}
});
내 어댑터입니다 :
public class ListToRefreshAdapter extends ArrayAdapter<ItemObject> {
protected Context myContext;
protected int resId;
protected ItemObject[] myListdata = null;
protected LayoutInflater myInflater = null;
public ListToRefreshAdapter(Context myContext, int resId, ItemObject[] myListData) {
super(myContext, resId, myListData);
this.myContext = myContext;
this.resId = resId;
this.myListdata = myListData;
myInflater = (LayoutInflater) myContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = myInflater.inflate(resId, null);
}
TextView title = (TextView) convertView.findViewById(R.id.titleItem);
TextView desc = (TextView) convertView.findViewById(R.id.descItem);
ImageView imgItem = (ImageView) convertView.findViewById(R.id.imgItem);
ItemObject itemObject = myListdata[position];
title.setText(itemObject.itemTitle);
desc.setText(itemObject.itemDesc);
imgItem.setBackgroundResource(R.drawable.item_no_picture);
return convertView;
}
}
누구는 내가 잘못하고있어 어떤 아이디어가있다? 도서관입니까 아니면 제 구현입니까?
고맙습니다. 답변 :