내 코드는 parsequeryadapter를 사용하여 구문 분석 백엔드에서 검색된 데이터를 표시합니다. 검색된 텍스트를 기반으로 내 코드는 기본적으로 사용자 정의 배경 및 일부 텍스트가있는 단추 인 listview에 일부 이미지를 표시합니다.ListItemClick이 ParseQueryAdapter를 사용하는 ListFragment에서 작동하지 않습니다.
문제는 onListItemClick 메서드가 전혀 호출되지 않는 것입니다. (호출하면 작동 할 수 있습니다)
코드 구성은 다음과 같습니다. NavActivity에는 XML에 정의 된 하위 listfragment가 포함 된 조각이 들어 있습니다.
이것은 내가 비 포커스와 같은 다른 구성 요소를 만드는 것은 문제를 해결할 것 here를 읽어 내 ParseQueryAdapter에서 getItemView 방법
@Override
public View getItemView(ParseObject object, View v, ViewGroup parent) {
if (v == null) {
v = View.inflate(context, R.layout.post_item, null);
}
super.getItemView(object, v, parent);
//find the elements here and set the value from the ParseObject returned
TextView1 = (TextView) v.findViewById(R.id.NumberTxtView);
Holder = (LinearLayout) v.findViewById(R.id.feloniesList);
if (object != null) {
Holder.removeAllViewsInLayout();
TextView1.setText(object.getString("comment"));
JSONArray jsonArray = object.getJSONArray("incident");
for (int i = 0; i < jsonArray.length(); i++) {
//Create a new button
Button button = new Button(getContext());
String btnText = null;
int resId = 0;
try {
//Get the string from the JSON Array
String item = jsonArray.getString(i);
button.setFocusable(false);
button.setText(item);
} catch (JSONException e) {
e.printStackTrace();
}
Holder.addView(button, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
}
}
return v;
}
ListItemClick 방법
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
feedObject = feedAdapter.getItem(position);
mListener.onListItemClicked(feedObject.getObjectId());
}
이지만, 그것은 도움이되지 않습니다. 어떤 도움을 주시면 감사하겠습니다