簡體   English   中英

Android模擬器運行時顯示空白

[英]Android emulator shows empty space when it is running

我已經編寫了一個簡單的android應用程序,用於從用戶那里獲取一些細節。但是當我在模擬器中運行它時,它什么也沒顯示,只有空白。 我使用Android Studio 1.2.2,在這里我同時附上了xml文件的設計和文本。 此外,設計視圖不會顯示在移動界面內部。

這是我的.xml文件

 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" tools:context=".mainActivity.fragmentHolder"> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content" android:weightSum="1"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:textSize="25dp" android:text="@string/label_new_claim_request" android:textStyle="bold" android:id="@+id/lbl_claim_request" android:layout_margin="20dp" android:layout_alignParentRight="true" android:layout_alignParentEnd="true"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/lbl_official_no" android:text="@string/label_official_no" android:textStyle="bold" android:textSize="15dp" android:textColor="#000000" android:layout_marginLeft="20dp" android:layout_alignParentRight="true" android:layout_alignParentEnd="true"/> <EditText android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/editText_official_no" android:layout_marginLeft="20dp" android:layout_marginRight="20dp" android:layout_marginBottom="20dp" android:textColor="#484848" android:hint="@string/label_official_no" android:layout_alignParentRight="true" android:layout_alignParentEnd="true"/> <Button android:layout_width="121dp" android:layout_height="wrap_content" android:textStyle="bold" android:textSize="20dp" android:text="@string/button_create" android:background="@drawable/button_style" android:id="@+id/loginButton" android:textColor="#ff000000" android:gravity="center" android:layout_marginLeft="20dp" android:layout_marginBottom="20dp" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_marginTop="31dp" android:layout_weight="0.83" /> </LinearLayout> </ScrollView> 

在此處輸入圖片說明

 public class fragmentHolder extends Activity { @Override public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) { super.onCreate(savedInstanceState, persistentState); setContentView(R.layout.activity_new_claim_request); } } 

最后,我找到了解決方案。 問題出在onCreate方法中。 onCreate方法應如下所示正確。

 public class fragmentHolder extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_new_claim_request); } } 

然后工作正常。

確保在覆蓋onCreate方法時,是否選擇了正確的方法。 有2種onCreate方法,分別是onCreate(Bundle savedInstanceState){}和onCreate((Bundle savedInstanceState,PersistableBundlepersistentState)){}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM