Why is my app's UI not showing on VS android app emulator (both API level 19 and 23)?

Green Yoshi

My app does show up in the emulator, but when I click on it the VS Emulator just shows a blank white screen for my app. enter image description here

Below is my code for my FirstLogin Activity

package com.example.android.fantappstic_app;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class FirstLogin extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_first_login);

        Button login_button = (Button) findViewById(R.id.login_button);
        final EditText user_field = (EditText)findViewById(R.id.user_field);
        final EditText pass_field = (EditText)findViewById(R.id.pass_field);
        Button signup_button = (Button) findViewById(R.id.signup_button);

        login_button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if(user_field.getText().toString().equals("codergal") && pass_field.getText().toString().equals("12345"))
                {
                    Intent GotoHomeScreen = new Intent(FirstLogin.this, HomeScreen.class);
                    FirstLogin.this.startActivity(GotoHomeScreen);
            }

                else
                {
                    Toast.makeText(getApplicationContext(), "Wrong Credentials",Toast.LENGTH_SHORT).show();

        }

    }
});
        signup_button.setOnClickListener(new View.OnClickListener() {
            @Override

            public void onClick(View v) {
                Intent GotoSignUpBasic = new Intent(FirstLogin.this, SignUpBasicInfo.class);
                FirstLogin.this.startActivity(GotoSignUpBasic);
            }
        });
    }}

Below is my XML File for FirstLogin Activity:

`<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.android.fantappstic_app.HomeScreen">

    <TextView
        android:id="@+id/login_welcome"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Welcome to App!"
        android:textSize="36sp"
        tools:layout_editor_absoluteY="47dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent" />

    <EditText
        android:id="@+id/user_field"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="textPersonName"
        android:text="Username"
        app:layout_constraintHorizontal_bias="0.502"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        tools:layout_editor_absoluteY="258dp" />

    <EditText
        android:id="@+id/pass_field"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="textPassword"
        android:text="Password"
        app:layout_constraintHorizontal_bias="0.502"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        tools:layout_editor_absoluteY="325dp" />

    <Button  
        android:id="@+id/login_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="74dp"
        android:onClick="login"
        android:text="Log In"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent" />

    <Button
        android:id="@+id/signup_button"
        style="@style/Widget.AppCompat.Button.Borderless"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="148dp"
        android:text="Sign Up"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginBottom="16dp" />
</android.support.constraint.ConstraintLayout>

And lastly, here is my AndroidManifest.xml file. I added FirstLogin as a parent function of HomeScreen activity.

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

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

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

    </application>

</manifest>

So basically, a) I'm not getting any errors anywhere b) I have designed components such as buttons and TextViews but they aren't showing up in VS Emulator. Additionally, my VS Emulator is a 5.7" Marshmallow (6.0.0) XHDPI Phone API Level 23. I also tried 5" KitKat (4.4) XXHDPI Phone API Level 19 as a different device too.

InziKhan

Here's the correct code.

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

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

                        <category android:name="android.intent.category.LAUNCHER" />
                    </intent-filter>
                </activity>
<activity android:name=".HomeScreen"
            android:parentActivityName=".FirstLogin" />
                <activity android:name=".SignUpBasicInfo"></activity>

            </application>

        </manifest>

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Will my app be slow on a device if it's slow on my Android Studio emulator?

分類Dev

Why is Eclipse's Android Device Chooser showing a fake emulator?

分類Dev

app not showing listview on real device but works on emulator

分類Dev

When I run my app on Android Studio, emulator starts but it says that the test app crashed

分類Dev

Issue with ISO 8601 in Android API level 23

分類Dev

android : spinner prompt not showing in API >23

分類Dev

How to run my android app in my huawei honor(Hol-U19) Mobile?

分類Dev

Android app runs only on emulator but not on device

分類Dev

Android Studio cant run app on emulator

分類Dev

Is it possible to change API level of mobile and test our app by using android app?

分類Dev

Please help my app keeps crashing on my phone and Emulator

分類Dev

Why does my android app only work in flight mode?

分類Dev

why my react app showing blank page after webpack-dev-server compilation?

分類Dev

Why do I have two of most default apps showing up in my app drawer?

分類Dev

Can't install Titanium's app on my android 2.3.6 phone

分類Dev

Will my portable app (Portable R) work on both my PC and Mac?

分類Dev

ui router vs ngroute for sinlge page app

分類Dev

App crashing in emulator

分類Dev

Accordion is not working in my android app

分類Dev

UI-Bootstrap Carousel won't cooperate with my Angular App. Why?

分類Dev

Android App is not running. Emulator says it keeps shutting down

分類Dev

Android Studio app runs on real device but won't run on an emulator

分類Dev

Installing phonegap app to android emulator using windows CLI

分類Dev

use both www and naked domain to point my heroku app

分類Dev

Why is Google Chrome mobile device emulator showing my 320 pixel wide site as it is?

分類Dev

My app crashes with a NullPointerException. Why?

分類Dev

Can't get Android App installed as System App on emulator to get past SecurityException for WRITE_APN_SETTINGS

分類Dev

In-app purchases (IAP) in android with BOTH Google and Facebook authentication?

分類Dev

Why does my app has the READ_PHONE_STATE permission although it's not declared in manifest?

Related 関連記事

  1. 1

    Will my app be slow on a device if it's slow on my Android Studio emulator?

  2. 2

    Why is Eclipse's Android Device Chooser showing a fake emulator?

  3. 3

    app not showing listview on real device but works on emulator

  4. 4

    When I run my app on Android Studio, emulator starts but it says that the test app crashed

  5. 5

    Issue with ISO 8601 in Android API level 23

  6. 6

    android : spinner prompt not showing in API >23

  7. 7

    How to run my android app in my huawei honor(Hol-U19) Mobile?

  8. 8

    Android app runs only on emulator but not on device

  9. 9

    Android Studio cant run app on emulator

  10. 10

    Is it possible to change API level of mobile and test our app by using android app?

  11. 11

    Please help my app keeps crashing on my phone and Emulator

  12. 12

    Why does my android app only work in flight mode?

  13. 13

    why my react app showing blank page after webpack-dev-server compilation?

  14. 14

    Why do I have two of most default apps showing up in my app drawer?

  15. 15

    Can't install Titanium's app on my android 2.3.6 phone

  16. 16

    Will my portable app (Portable R) work on both my PC and Mac?

  17. 17

    ui router vs ngroute for sinlge page app

  18. 18

    App crashing in emulator

  19. 19

    Accordion is not working in my android app

  20. 20

    UI-Bootstrap Carousel won't cooperate with my Angular App. Why?

  21. 21

    Android App is not running. Emulator says it keeps shutting down

  22. 22

    Android Studio app runs on real device but won't run on an emulator

  23. 23

    Installing phonegap app to android emulator using windows CLI

  24. 24

    use both www and naked domain to point my heroku app

  25. 25

    Why is Google Chrome mobile device emulator showing my 320 pixel wide site as it is?

  26. 26

    My app crashes with a NullPointerException. Why?

  27. 27

    Can't get Android App installed as System App on emulator to get past SecurityException for WRITE_APN_SETTINGS

  28. 28

    In-app purchases (IAP) in android with BOTH Google and Facebook authentication?

  29. 29

    Why does my app has the READ_PHONE_STATE permission although it's not declared in manifest?

ホットタグ

アーカイブ