簡體   English   中英

我無法在android studio模擬器屏幕上查看我的應用

[英]I am unable to view my app on the android studio emulator screen

我無法在android studio模擬器屏幕上查看我的應用。 我嘗試使用GPU主機,增加的Ram,固定的HAXM,固定的VT-X。 我認為問題可能出在我的代碼上。 由於我是Android和Java的新手。 我還將包括java文件和xml文件。 我嘗試重新啟動,從而降低了API級別。 android logcat也已附上。 這個應用程式嘗試將兩個數字相加。

Java代碼:

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends ActionBarActivity{


    Button add;
    TextView ans;
    EditText n1, n2;

    @Override
    public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
        super.onCreate(savedInstanceState, persistentState);
        setContentView(R.layout.activity_main);
        add = (Button) findViewById(R.id.button1);
        ans = (TextView) findViewById(R.id.textView1);
        n1 = (EditText) findViewById(R.id.editText1);
        n2 = (EditText) findViewById(R.id.editText2);
        add.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                int a,b,c;
                a = Integer.parseInt(n1.getText().toString());
                b = Integer.parseInt(n2.getText().toString());
                c = a+b;
                ans.setText(""+c);

            }
        });
    }

}

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" android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"
    android:id="@+id/layout1">

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="numberSigned"
        android:ems="10"
        android:id="@+id/editText1"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_marginLeft="50dp"
        android:layout_marginStart="50dp"
        android:layout_marginTop="35dp"
        android:layout_alignParentEnd="true"
        android:gravity="right" />

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="numberSigned"
        android:ems="10"
        android:id="@+id/editText2"
        android:layout_below="@+id/editText1"
        android:layout_alignLeft="@+id/editText1"
        android:layout_alignStart="@+id/editText1"
        android:layout_marginTop="32dp"
        android:gravity="right" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="SUM"
        android:id="@+id/button1"
        android:layout_below="@+id/editText2"
        android:layout_alignLeft="@+id/editText2"
        android:layout_alignStart="@+id/editText2"
        android:layout_marginTop="35dp" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="0"
        android:id="@+id/textView1"
        android:layout_below="@+id/button1"
        android:layout_alignLeft="@+id/button1"
        android:layout_alignStart="@+id/button1"
        android:layout_marginTop="43dp" />
</RelativeLayout>

android logcat:

04-10 04:01:54.310    2143-2159/com.tandh.myfirstapp D/OpenGLRenderer﹕ Render dirty regions requested: true
04-10 04:01:54.310    2143-2143/com.tandh.myfirstapp D/﹕ HostConnection::get() New Host Connection established 0x7f10fcffae80, tid 2143
04-10 04:01:54.410    2143-2143/com.tandh.myfirstapp D/Atlas﹕ Validating map...
04-10 04:01:54.450    2143-2159/com.tandh.myfirstapp D/﹕ HostConnection::get() New Host Connection established 0x7f10fcffb3c0, tid 2159
04-10 04:01:54.480    2143-2159/com.tandh.myfirstapp I/OpenGLRenderer﹕ Initialized EGL, version 1.4
04-10 04:01:54.500    2143-2159/com.tandh.myfirstapp D/OpenGLRenderer﹕ Enabling debug mode 0
04-10 04:01:54.550    2143-2159/com.tandh.myfirstapp **W/EGL_emulation﹕ eglSurfaceAttrib not implemented**
04-10 04:01:54.550    2143-2159/com.tandh.myfirstapp **W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0x7f10fcffe700, error=EGL_SUCCESS**

清單代碼:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.tandh.myfirstapp" >

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

您需要確保擁有必需的ARM EABI v7a系統映像和目標API的Android SDK 例如,如果您正在為API 15開發應用程序,則需要檢查是否具有API 15的系統映像和SDK。

暫無
暫無

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

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