Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Web サービスからデータをロードする ListView を使用したアクティビティがあります。カスタムアダプタークラスを介してロードされる各リスト項目にボタンがあります。アダプター クラスでボタン イベントを処理しています。ここで必要なのは、ボタン クリック イベントのアダプタ クラスから ListView を使用してアクティビティを終了することです。
button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ((Activity)context).finish(); } });
ボタンクリックイベントでこのコードを使用します
アクティビティ コンテキストを取得したら、your_context.finish() を実行できます。