簡體   English   中英

我試圖在模擬器中運行該應用程序,但未顯示第一個活動。 它只是打開並顯示白屏

[英]I tried to run the app in the emulator but its not showing the first activity. it just opens and shows a white screen

logcat-

    --------- beginning of system
10-24 17:40:01.419    1309-1675/? I/ActivityManager﹕ START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER]  flg=0x10200000 cmp=com.apsdevelopers.mr.meteout/.mottoscreen (has extras)} from uid 10008 on display 0
10-24 17:40:01.665    1917-1917/? I/Choreographer﹕ Skipped 120 frames!  The application may be doing too much work on its main thread.
10-24 17:40:01.950    2026-2037/? I/art﹕ CollectorTransition marksweep + semispace GC freed 1303(40KB) AllocSpace objects, 0(0B) LOS objects, 42% free, 697KB/1209KB, paused 149.640ms total 149.640ms
10-24 17:40:01.961    1917-1917/? I/Choreographer﹕ Skipped 73 frames!  The application may be doing too much work on its main thread.
10-24 17:40:02.284    1917-1917/? I/Choreographer﹕ Skipped 32 frames!  The application may be doing too much work on its main thread.
10-24 17:40:02.444    1917-1917/? I/Choreographer﹕ Skipped 37 frames!  The application may be doing too much work on its main thread.
10-24 17:40:02.595    1917-1917/? I/Choreographer﹕ Skipped 30 frames!  The application may be doing too much work on its main thread.
10-24 17:40:02.733    1917-1917/? I/Choreographer﹕ Skipped 34 frames!  The application may be doing too much work on its main thread.
10-24 17:40:02.873    1917-1917/? I/Choreographer﹕ Skipped 30 frames!  The application may be doing too much work on its main thread.
10-24 17:40:03.152    1917-1917/? I/Choreographer﹕ Skipped 37 frames!  The application may be doing too much work on its main thread.
10-24 17:40:03.257    1309-1328/? I/Choreographer﹕ Skipped 411 frames!  The application may be doing too much work on its main thread.
10-24 17:40:03.445    1917-1917/? I/Choreographer﹕ Skipped 46 frames!  The application may be doing too much work on its main thread.
10-24 17:40:03.537    1309-1328/? I/Choreographer﹕ Skipped 70 frames!  The application may be doing too much work on its main thread.
10-24 17:40:03.606    1917-1917/? I/Choreographer﹕ Skipped 39 frames!  The application may be doing too much work on its main thread.
10-24 17:40:03.892    1917-1917/? I/Choreographer﹕ Skipped 34 frames!  The application may be doing too much work on its main thread.
10-24 17:40:03.888    1309-1328/? I/Choreographer﹕ Skipped 52 frames!  The application may be doing too much work on its main thread.
10-24 17:40:04.597    1309-1328/? I/ActivityManager﹕ Displayed com.apsdevelopers.mr.meteout/.mottoscreen: +2s813ms
10-24 17:40:04.814    1309-1328/? I/Choreographer﹕ Skipped 30 frames!  The application may be doing too much work on its main thread.

我的第一個活動(mottoscreen)java文件-

package com.apsdevelopers.mr.meteout;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;




public class mottoscreen extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_mottoscreen, menu);
    return true;
}

public void onButtonClick(View v) {


        if (v.getId() == R.id.bLOGIN) {
            Intent I = new Intent(mottoscreen.this, circles.class);
            startActivity(I);
        }
}


@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}
}

我的第一個活動(mottoscreen)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=".mottoscreen"
android:background="#9acef6fe"
android:contextClickable="false"
android:id="@+id/activity_mottoscreen">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="#SELL SCRAP ?"
    android:id="@+id/textView"
    android:textColor="#d4375a5c"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_alignRight="@+id/bLOGIN"
    android:layout_alignEnd="@+id/bLOGIN" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="#DONATE TO CHILDREN ?"
    android:id="@+id/textView2"
    android:password="false"
    android:layout_below="@+id/textView"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_marginTop="38dp"
    android:textColor="#d4375a5c" />

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="PROCEED"
    android:id="@+id/bLOGIN"
    android:onClick="onButtonClick"
    android:textSize="25sp"
    android:background="#e33a9179"
    android:textColor="#ffffff"
    android:layout_alignParentBottom="true"
    android:layout_alignRight="@+id/textView4"
    android:layout_alignEnd="@+id/textView4"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="#HELP THE OLD ?"
    android:id="@+id/textView3"
    android:password="false"
    android:textColor="#d4375a5c"
    android:layout_below="@+id/textView2"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_marginTop="36dp" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="CLICK PROCEED TO MAKE THE WORLD A BETTER PLACE..."
    android:id="@+id/textView4"
    android:password="false"
    android:textColor="#d95c5c5d"
    android:layout_above="@+id/bLOGIN"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_marginBottom="58dp" />
</RelativeLayout>

我不知道發生了什么。 我也嘗試過在真實設備上運行該應用程序,但是它打開並沒有顯示任何內容。 有人請幫忙。 提前致謝

您錯過了onCreate中的setContenView(R.layout.mottoscreen)。 請在活動的onCreate內將視圖設置為活動。

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

暫無
暫無

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

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