2015-09-06 152 views
0

我只是在使用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; 
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是这样的

我想从这项活动的第二项活动被命名为目录移动 Java是

package com.example.lenovo.shop_easy; 

import android.app.Activity; 
import android.content.Intent; 
import android.os.Bundle; 
import android.view.Menu; 
import android.view.MenuItem; 
import android.view.View; 

public class catalog extends Activity { 

@Override 

protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_catalog); 
} 

@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_catalog, 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 sendMessage(View view) { 
    Intent intent = new Intent(catalog.this, product1.class); 
    startActivity(intent); 
} 
public void sendMessage1(View view) { 
    Intent intent = new Intent(catalog.this, PRODUCT2.class); 
    startActivity(intent); 
} 
public void sendMessage2(View view) { 
    Intent intent = new Intent(catalog.this, PRODUCT3.class); 
    startActivity(intent); 
} 
public void sendMessage3(View view) { 
    Intent intent = new Intent(catalog.this, product4.class); 
    startActivity(intent); 
} 
public void sendMessage4(View view) { 
    Intent intent = new Intent(catalog.this, product5.class); 
    startActivity(intent); 
} 
public void sendMessage5(View view) { 
    Intent intent = new Intent(catalog.this, product6.class); 
    startActivity(intent); 
} 
public void sendMessage6(View view) { 
    Intent intent = new Intent(catalog.this, product7.class); 
    startActivity(intent); 
} 
public void sendMessage7(View view) { 
    Intent intent = new Intent(catalog.this, product8.class); 
    startActivity(intent); 
} 
public void sendMessage8(View view) { 
    Intent intent = new Intent(catalog.this, product9.class); 
    startActivity(intent); 
} 
public void sendMessage9(View view) { 
    Intent intent = new Intent(catalog.this, product10.class); 
    startActivity(intent); 
} 

} 




    <FrameLayout 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=".frontpagee" 
    android:background="@drawable/back"> 

    <ImageView 
    android:layout_width="472dp" 
    android:layout_height="500dp" 
    android:id="@+id/imageView11" 
    android:src="@mipmap/cover" 
    android:layout_gravity="center_horizontal|top" 
    android:contentDescription="@string/content" /> 

    <Button 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/text12" 
    android:id="@+id/button11" 
    android:layout_gravity="center_horizontal|bottom" 
    android:textSize="@dimen/size2" 
    android:clickable="true" 
    android:onClick="sendMessage"/> 

    </FrameLayout> 

代码是正确的说android的工作室,但是当我在我的手机上运行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> 

做什么

回答

2

您还没有覆盖在class frontpageeonCreate(Bundle savedInstance)方法,并没有叫它setContentView(R.layout...)