私は現在、EclipseでAndroidアプリを開発しています。基本的に、画像ボタンの上にテキストを配置する必要があります。そのイメージボタンの上にテキストを配置するための条件ステートメントがいくつかあります。そのため、テキストをxmlに設定できません
これは、xml で imagebutton を設定する方法です。
<ImageButton
android:id="@+id/question1"
android:layout_width="150dip"
android:layout_height="50dip"
android:layout_gravity="center_vertical|center"/>
これは、ボタンの画像ソースとテキストを設定する方法です。
buttonQuestion1 = (ImageButton) findViewById(R.id.question1);
TextView listContent = (TextView)findViewById(R.id.question1);
String question1 = getQuestion.get(0);
buttonQuestion1.setImageResource(R.drawable.button);
listContent.setText(question1);
画像ソースを設定するコードは正常に機能します。イメージボタンの上にテキストを配置するために TextView と setText を使用していますが、実行しようとするとアプリがクラッシュします。イメージボタンの上に正しい方法でテキストを設定する方法を知っている人はいますか?