0

こんにちは、このボタン スタイルをより具体的には「バスケットの表示」ボタンを再作成しようとしています。waitrose appボタンには、テキスト サイズやフォントの色などが異なる複数行のテキストが必要です。

ここまでのコードです。ボタンとその表示を正しく作成しましたが、クリックすると押された状態が機能しません。どこが間違っているのですか。前もって感謝します。

xml ボタン ファイル:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" 

    android:state_pressed="true"
    android:state_focused="true"
    android:background="@drawable/button_bg" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Some Text"

    android:state_pressed="false"
    android:state_focused="false"
        android:textColor="#ffffff" />

     <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Some Text"

    android:state_pressed="false"
    android:state_focused="false"
        android:textColor="#ffffff" />

</LinearLayout>

java file code:


    package com.buttons2;

    import com.buttons2.R;

    import android.app.Activity;
    import android.os.Bundle;
    import android.widget.Button;

    public class Buttons2Activity extends Activity {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);

            Button button = (Button) findViewById(R.id.button1);
            setContentView(R.layout.button);


        }
    }
4

1 に答える 1

0

テキストと画像のクリックを処理するコードを記述し、それを使用してメインのコンテナー ビューの選択/非選択状態を具体的に設定する必要があると思います (正しい押されたボタンの状態を表示するため)。

于 2012-04-09T19:04:12.287 に答える