我有這段代碼的問題。我有我的XML註冊的ID,但代碼不起作用。主要是紅色的,add_photo是紅色的,目標圖像和目標圖像都是紅色的(紅色的一切都是斜體的)。XML準備就緒,Java未成功
setContentView(R.layout.*main*);
Button buttonAddPhoto = (Button)findViewById(R.id.*add_photo*);
textTargetUri = (TextView)findViewById(R.id.*targeturi*);
targetImage = (ImageView)findViewById(R.id.*targetimage*);
XML:
<TextView
android:text= "Thot of The Day!"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="60sp"
android:layout_centerHorizontal="true"
android:gravity="center"
android:id="@+id/text_shout_out"
/>
<Button
android:id="@+id/add_photo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Add Photo"
android:gravity="center"
android:layout_below="@+id/text_shout_out"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="131dp"
android:onClick="Image"/>
也發佈您的佈局文件。 –
你真的在你的代碼中使用星號嗎? –
用佈局文件編輯你的問題。不要把它當作評論。 –