私は GridView
ネストされた ListView
このような:
ListView
イベント(行)が含まれ、 GridView
参加しているユーザー(行項目)。今添付したい OnItemClickListener
わたしの ListView
しかし、行をクリックしても何も起こりません。私は問題をデバッグしようとしましたが、Androidが設定されているリスナーを探していることがわかりました GridView
行クリック中に。リスナーを呼び出したい ListView
しかし、強制する方法がわかりません。
回答:
回答№1は1GridView
行のほとんどのスペースをその親(ListView
)タッチ不可になります。 あなたが作る必要があります GridView
スクロールできません。拡張することで可能 GridView
onMeasureメソッドをovveriding
public class NonScrollableGridView extends GridView {
public NonScrollableGridView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// Do not use the highest two bits of Integer.MAX_VALUE because they are
// reserved for the MeasureSpec mode
int heightSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, heightSpec);
getLayoutParams().height = getMeasuredHeight();
}
}
もう1つの選択肢は、 RecyclerView
〜と GridLayoutManager
insted of ListView
使用していない GridView