2

android:textOnとのandroid:textOff属性を変更してSwitchも、S3 では機能しません。スイッチのラベル​​には常に「ON」「OFF」が表示されています。

Switchドキュメンテーション

<Switch
                        xmlns:android="http://schemas.android.com/apk/res/android"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textOn="@string/on"
                        android:textOff="@string/off"
                        android:includeFontPadding="false"/>
4

2 に答える 2

0

これを Samsung Galaxy S3 でテストしたところ、問題なく動作しました。

ここに私のXMLがあります

<RelativeLayout 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"
    tools:context=".MainActivity" >

    <ToggleButton
        android:id="@+id/toggleButton1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/switch1"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="16dp"
        android:textOn="CHANGEMEON"
        android:textOff="CHANGEMOFF"
        android:text="ToggleButton" />

</RelativeLayout>
于 2013-03-01T15:53:12.947 に答える
-1

次のコードを試してください:

      toggle=(ToggleButton)findViewById(R.id.tglbtn);
      toggle.setOnClickListener(new OnClickListener() {
      public void onClick(View v) {
       // TODO Auto-generated method stub
      if(toggle.isChecked())
      {
       Toast.makeText(getApplicationContext(), "The state is changed to on", Toast.LENGTH_LONG).show();
       }
        else
        {
          Toast.makeText(getApplicationContext(), "The state is changed to off", Toast.LENGTH_LONG).show();
         }
         }
         });
于 2013-03-01T15:49:39.493 に答える