0

基本的に、次のことを行うプログラムを作成しようとしていますが、ボタンを見つけてそれらを使用してアクティビティを移行するのに問題があります。ボタンを押す以外の入力は必要ありません。

1-質問を含むテキストビュー。質問への回答を表示する2-ボタン。ボタンのクリックによって提供される回答に配置する 3-Textview。4-同じようにフォーマットされた次のアクティビティを表示するためのボタン (5 回繰り返されます) 5-アプリケーションをすべて一緒に終了するためのボタンも必要です。

これはおそらく最もレベルの低い質問の 1 つだと思いますが、ボタンで何かを実行する方法がわかりません (上記のリストのパート 2、4、および 5)。

ボタンが押されるまで質問への回答を最初に非表示に設定してから、それを明らかにすることに関係があると思います。

この初級レベルの問題を教えてください!:(

以下は私のレイアウト ファイルです。メインの Java ファイルはこのプロジェクトにとってかなりけちなので、現在の状態では添付されません。解決しようとしているレイアウトの問題がほとんどです。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

<Textview android:id="@+id/Questions"
    android:layout_weight="1"
    android:layout_width="wrap_content"
    android:layout_height="0dip"
    android:text="@string/Q1"   />

<Button android:id="@+id/QButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/button_question" 
android:onClick="buttonQuestion" />

<Button android:id="@+id/AButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/button_send" 
    android:onClick="buttonAnswer"/>

<Textview android:id="@+id/Answers"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:hint="@string/edit_message"
android:onClick="sendMessage" />

<Button android:id="@+id/QuitButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/button_quit" 
    android:onClick="buttonQuit"/>

4

2 に答える 2

0

必要なことは、このレイアウトを使用している Java クラスの各ボタンのメソッドを作成することだけです。

public void buttonQuestion(View v){
        TextView answerText = (TextView) findViewById(R.id.Answers);
        answerText.setText("Your answer");
    }

public void buttonAnswer(View v){
            //do something
        }

public void sendMessage(View v){
            //do something
        }

public void buttonQuit(View v){
            finish();
        }
于 2013-10-30T09:36:37.167 に答える