在我的手机上将Android Studio作为已安装的应用程序运行时,它仅显示白屏。什么都没有显示,但是当我在Android Studio上运行它时,没有错误。 如果有人可以请让我知道为什么,它将非常感激。 /
我的主要XML:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:fillViewport="true"
android:layout_height="fill_parent" >
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
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"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:showIn="@layout/activity_main"
tools:context="com.app.anna.androidportfolioapp.MainActivity"
android:visibility="visible">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_below="@+id/textView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="@+id/linearLayout"
android:weightSum="1">
<Button
style="@style/ButtonValues"
android:layout_marginTop="10dp"
android:layout_width="318dp"
android:layout_height="wrap_content"
android:text="Spotify Streamer"
android:id="@+id/sunshineButton" />
<Button
style="@style/ButtonValues"
android:layout_width="318dp"
android:layout_height="wrap_content"
android:text="Scores App"
android:id="@+id/scoresButton" />
<Button
style="@style/ButtonValues"
android:layout_width="318dp"
android:layout_height="wrap_content"
android:text="Library App"
android:id="@+id/libraryButton" />
<Button
style="@style/ButtonValues"
android:layout_width="318dp"
android:layout_height="wrap_content"
android:text="Build it Bigger"
android:id="@+id/buildBiggerButton" />
<Button
style="@style/ButtonValues"
android:layout_width="318dp"
android:layout_height="wrap_content"
android:text="Bacon Reader"
android:id="@+id/baconButton" />
<Button
style="@style/ButtonValues"
android:layout_width="318dp"
android:layout_height="wrap_content"
android:text="Capstone My Own App"
android:id="@+id/capstoneButton" />
<ImageView
android:layout_width="93dp"
android:layout_height="93dp"
android:id="@+id/portfolioIcon"
android:alpha="0.5"
android:layout_gravity="center_horizontal"
android:layout_marginTop="4dp"
android:layout_marginLeft="5dp"
android:src="@mipmap/ic_launcher"
android:adjustViewBounds="true"
android:nestedScrollingEnabled="true" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Annat.huynh@yahoo.com"
android:id="@+id/textView"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="55dp" />
这是我的主要.java
package com.app.anna.androidportfolioapp;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
@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_main, menu);
return true;
}
@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);
}
public void openApp(View view) {
Toast.makeText(getApplicationContext(), "Opens Spotify Streamer App",
Toast.LENGTH_SHORT).show();
}
public void openApp2(View view) {
Toast.makeText(getApplicationContext(), "Opens Scores App",
Toast.LENGTH_SHORT).show();
}
public void openApp3(View view) {
Toast.makeText(getApplicationContext(), "Opens Library App",
Toast.LENGTH_SHORT).show();
}
public void openApp4(View view) {
Toast.makeText(getApplicationContext(), "Opens Build It Bigger App",
Toast.LENGTH_SHORT).show();
}
public void openApp5(View view) {
Toast.makeText(getApplicationContext(), "Opens Bacon App",
Toast.LENGTH_SHORT).show();
}
public void openApp6(View view) {
Toast.makeText(getApplicationContext(), "Opens Capstone My Own App",
Toast.LENGTH_SHORT).show();
}
答案 0 :(得分:3)
在public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
main
应该是您的布局名称。
答案 1 :(得分:0)
请在您的清单中看到他们的午餐者活动代码可能会解密超过一次
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>