儘管有太多的擺弄,我無法使我的TextView可見。我的TextView文本不可見
我已經設置了一個字符串,該字符串應該包含要在TextView中顯示的文本,但文本在圖形佈局中永遠不會顯示。即使我用 「機器人:文本=」 文本」,並更改尺寸,外觀等,沒有什麼變化
我的Java代碼:
public class MainClass extends Activity {
float goldCount = 0.0f;
ImageView minionClick;
TextView textGoldCount;
String textTotal;
@Override
public void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mainlayout);
minionClick = (ImageView) findViewById(R.id.minioncentreid);
textGoldCount = (TextView) findViewById(R.id.textviewtop);
textTotal = goldCount + " Gold";
textGoldCount.setText(textTotal);`
我的XML代碼:
`<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainlayoutid"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/mainbackground"
>
<TextView
android:id="@+id/textviewtop"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="25">
</TextView>
<ImageView
android:id="@+id/minioncentreid"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="50"
android:contentDescription="@+string/desc"
android:src="@drawable/minioncentrethree"
/>
<TextView
android:id="@+id/textviewbottom"
android:layout_weight="25"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
>
</TextView>
`
底部TextView是被那裏,在中間圖像居中,而我剛剛刪除它,並選中,但它沒有解決問題。
你可以改變LinearLayout的背景圖像而不是檢查。 –
我沒有看到您的代碼和佈局的任何問題。檢查你的代碼的其他部分。 – Libin