0

Androidスタジオの同じJavaクラス内で3つのボタン、マップ、テキストと写真につながるボタン、最後の1つはビデオを開くことができるようにしたい..次のコードを使用しました:

    public void location(View view) {

    Button great = (Button) findViewById(R.id.location);
    great.setOnClickListener(new View.OnClickListener() {

    @Override
    public void onClick(View view) {
    // TODO Auto-generated method stub
    Intent intent = new Intent(getApplicationContext(),location`enter code here`.class);
     startActivity(intent);
        }
    });
}

他の 2 つのボタンも同様です。.xmlファイルについて

   <Button
    android:layout_width="150dp"
    android:layout_height="wrap_content"
    android:text="@string/history"
    android:id="@+id/button"
    android:onClick="location"
    android:layout_gravity="center_horizontal"
    android:layout_marginTop="10dp"/>

そして文字列は

<string name="map">Map</string>
<string name="location">Location</string>
<string name="info">information about related subject
</string>

問題は、同じメイン レイアウトで 3 つのボタンすべてを開くにはどうすればよいかということです。使いますか

public void onClick(View view) {
    Intent intent = new Intent(getApplicationContext(),location`enter code here`.class);
}

3つのボタンすべてで?または、各ボタンを別の Java クラスに割り当てる必要がありますか? 特に、メインの Java ですべての API 設定 (Google マップのインポート) が灰色で表示される場合は?

4

0 に答える 0