0

実行時にボタンをTextViewonclickに変換することは可能ですか?

ありがとうクリス

4

3 に答える 3

1

あなたがやろうとしているのは悪いデザインです。

ボタンを非表示にして、代わりにTextViewを表示します。

于 2010-06-04T06:22:18.737 に答える
0

TextViewとButtonの両方を保持するレイアウトを定義できます。setVisibility(Visibility.VISIBLE)実行時に1つと他を設定するだけですsetVisibility(Visibility.INVISIBLE)

于 2010-06-04T06:38:55.583 に答える
0

非常に優れたテクニックであるViewSwitcherを使用できます。ここでは、ボタンSimpleでedittextを変更するだけです:)

例えば

XML

<ViewSwitcher
            android:id="@+id/my_switcher"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" >

            <TextView
                android:id="@+id/clickable_text_view"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:clickable="true"
                android:onClick="TextViewClicked"
                android:text="abc"
                android:textColor="@color/white"
                android:textSize="16sp" >
            </TextView>

            <EditText
                android:id="@+id/hidden_edit_view"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:hint="12"
                android:text="12"
                android:textColor="@color/white"
                android:textSize="16sp" >
            </EditText>
        </ViewSwitcher>

JAVA

    ViewSwitcher my_switcher;
my_switcher = (ViewSwitcher) findViewById(R.id.my_switcher);
TextView profile_name = (TextView) findViewById(R.id.clickable_text_view);

profile_name.setOnTouchListener(new OnTouchListener() {

            @Override
            public boolean onTouch(View v, MotionEvent event) {
                // TODO Auto-generated method stub
TextViewClicked();
}
        });

TextViewClicked()

public void TextViewClicked() {
        my_switcher.showNext(); //or switcher.showPrevious();
        TextView myTV = (TextView) my_switcher.findViewById(R.id.clickable_text_view);
        myTV.setText("value");
    }

お役に立てば幸いです

于 2016-03-10T12:41:44.170 に答える