TextViews のリストがあり、ユーザーがボタンをクリックすると、対応する TextView で performClick() を実行します (QuickAction をトリガーするため)。これ?
これは私が TextView を作成する方法です
//The holder of a store, which contains a TextView
public List<Store> stores = new ArrayList<Store>();
// Create TextView and QuickAction within loop in method createStores();
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lp.leftMargin = Math.round(location[0]);
lp.topMargin = Math.round(location[1]);
lp.gravity = Gravity.TOP | Gravity.LEFT;
TextView tv = new TextView(getContext());
tv.setTag(s);
tv.setLayoutParams(lp);
tv.setText(s.name);
final QuickAction quickAction = new QuickAction(getContext(), QuickAction.VERTICAL);
ActionItem nextItem = new ActionItem(s.ID, s.name, null, s.ID);
quickAction.addActionItem(nextItem);
tv.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
quickAction.show(v, null);
}
});
s.textview = tv;
次に、店のリストから店を見つけて、performClick() メソッドでクリックをシミュレートしたい検索メソッドがあります。OnClickListener が呼び出されますが、TextView が null であるため、QuickAction が正しく配置されていません
// Then from another function
s.textview.performClick();
==== 更新 ===== 私は自分の問題を解決しました。助けてくれてありがとう!