我已经能够对ListView
取决于位置的每个特定项目做很多事情。现在,我正在尝试更改其中的图像,ImageView
但ListView
由于某种原因我不能。每次点击它时,ImageView
它下方或上方的几个位置反而会发生变化。
我正在使用一个ParseQueryAdapter
.
public class MyCustomAdapter extends ParseQueryAdapter<ParseObject> {
public MyCustomAdapter(Context context, String className,
int itemViewResource) {
super(context, className, itemViewResource);
}
@Override
public View getItemView(final ParseObject status, View convertView, ViewGroup parent) {
convertView = View.inflate(getActivity().getApplicationContext(), R.layout.status_list_view_item, null);
mListViewReferences(convertView, status);
statusText = (TextView) convertView.findViewById(R.id.statusText);
statusText.setText(status.getString("Status"));
// Set the count number for the like counter depending on the users that liked it
likeCounter = (TextView) convertView.findViewById(R.id.likeCounter);
likeCounter.setText("" + status.getInt("likeCount"));
................
return super.getItemView(status, convertView, parent);
}
/**
* Set References
* @param View view
* @param ParseObject status
*/
private void mListViewReferences(final View view, final ParseObject status) {
statusLike = (ImageButton) view.findViewById(R.id.statusLike);
/**
* onClickListeners and actions to perform
*/
//Like/Unlike current status
statusLike.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
/**
I want to do it in here, i want to change the image of "statusLike" in here depending on the position.
*/
}
});
}
我已经尝试了很多方法,并且我还将它包含在我正在使用的当前 if/else 语句中,但它仍然不起作用。likeCount 有效,状态文本和标题也有效。除了更改当前子位置内的图像外,一切正常。