Java 应用程序运行时不显示任何内容
我使用android studio才一天大。我必须为我的学校项目创建一个应用程序,我做到了,我在android studio中编程,它没有错误。请帮忙, 这是名为frontpagee的主要活动Java 应用程序运行时不显示任何内容,java,android,xml,android-intent,android-studio,Java,Android,Xml,Android Intent,Android Studio,我使用android studio才一天大。我必须为我的学校项目创建一个应用程序,我做到了,我在android studio中编程,它没有错误。请帮忙, 这是名为frontpagee的主要活动 package com.example.lenovo.shop_easy; import android.app.Activity; import android.content.Intent; import android.view.Menu; import android.view.MenuItem
package com.example.lenovo.shop_easy;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
public class frontpagee extends Activity
{
public void sendMessage(View view){
Intent intent = new Intent(frontpagee.this, catalog.class);
startActivity(intent);
}
@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_frontpagee, 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);
}
}
XML是这样的
我想从这个活动转到第二个名为Catalog的活动
java是
package com.example.lenovo.shop\u easy;
导入android.app.Activity;
导入android.content.Intent;
导入android.os.Bundle;
导入android.view.Menu;
导入android.view.MenuItem;
导入android.view.view;
公共类目录扩展了活动{
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_目录);
}
@凌驾
公共布尔onCreateOptions菜单(菜单){
//为菜单充气;这会将项目添加到操作栏(如果存在)。
getMenuInflater().充气(R.menu.menu\u目录,菜单);
返回true;
}
@凌驾
公共布尔值onOptionsItemSelected(菜单项项){
//处理操作栏项目单击此处。操作栏将
//自动处理Home/Up按钮上的点击,只要
//在AndroidManifest.xml中指定父活动时。
int id=item.getItemId();
//noinspection SimplifiableIf语句
if(id==R.id.action\u设置){
返回true;
}
返回super.onOptionsItemSelected(项目);
}
公共无效发送消息(查看){
意向意向=新意向(catalog.this,product1.class);
星触觉(意向);
}
公共无效发送消息1(查看){
意向意向=新意向(catalog.this,PRODUCT2.class);
星触觉(意向);
}
公共无效发送消息2(查看){
意向意向=新意向(catalog.this,PRODUCT3.class);
星触觉(意向);
}
公共无效发送消息3(查看){
意向意向=新意向(catalog.this,product4.class);
星触觉(意向);
}
公共无效发送消息4(查看){
意向意向=新意向(catalog.this,product5.class);
星触觉(意向);
}
公共无效发送消息5(查看){
意向意向=新意向(catalog.this,product6.class);
星触觉(意向);
}
公共无效发送消息6(查看){
意向意向=新意向(catalog.this,product7.class);
星触觉(意向);
}
公共无效发送消息7(查看){
意向意向=新意向(catalog.this,product8.class);
星触觉(意向);
}
公共无效发送消息8(查看){
意向意向=新意向(catalog.this,product9.class);
星触觉(意向);
}
公共无效发送消息9(查看){
意向意向=新意向(catalog.this,product10.class);
星触觉(意向);
}
}
android studio说,代码是正确的,但当我在手机上运行adb时,它会安装应用程序,一切正常,但当我打开应用程序时,它只会在顶部显示应用程序图标和名称,而不会显示其他操作。请帮忙
这里也是主xml文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.lenovo.shop_easy" >
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".frontpagee"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".catalog"
android:label="@string/title_activity_catalog" >
</activity>
<activity
android:name=".product1"
android:label="@string/title_activity_product1" >
</activity>
<activity
android:name=".PRODUCT2"
android:label="@string/title_activity_product2" >
</activity>
<activity
android:name=".PRODUCT3"
android:label="@string/title_activity_product3" >
</activity>
<activity
android:name=".product4"
android:label="@string/title_activity_product4" >
</activity>
<activity
android:name=".product5"
android:label="@string/title_activity_product5" >
</activity>
<activity
android:name=".product6"
android:label="@string/title_activity_product6" >
</activity>
<activity
android:name=".product7"
android:label="@string/title_activity_product7" >
</activity>
<activity
android:name=".product8"
android:label="@string/title_activity_product8" >
</activity>
<activity
android:name=".product9"
android:label="@string/title_activity_product9" >
</activity>
<activity
android:name=".product10"
android:label="@string/title_activity_product10" >
</activity>
</application>
</manifest>
怎么办您没有在
类frontpagee
中重写onCreate(Bundle savedInstance)
方法,也没有在其中调用setContentView(R.layout…
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.lenovo.shop_easy" >
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".frontpagee"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".catalog"
android:label="@string/title_activity_catalog" >
</activity>
<activity
android:name=".product1"
android:label="@string/title_activity_product1" >
</activity>
<activity
android:name=".PRODUCT2"
android:label="@string/title_activity_product2" >
</activity>
<activity
android:name=".PRODUCT3"
android:label="@string/title_activity_product3" >
</activity>
<activity
android:name=".product4"
android:label="@string/title_activity_product4" >
</activity>
<activity
android:name=".product5"
android:label="@string/title_activity_product5" >
</activity>
<activity
android:name=".product6"
android:label="@string/title_activity_product6" >
</activity>
<activity
android:name=".product7"
android:label="@string/title_activity_product7" >
</activity>
<activity
android:name=".product8"
android:label="@string/title_activity_product8" >
</activity>
<activity
android:name=".product9"
android:label="@string/title_activity_product9" >
</activity>
<activity
android:name=".product10"
android:label="@string/title_activity_product10" >
</activity>
</application>
</manifest>