Reputation: 5
I am only a day old in using android studio. I have to create an app for my school project, i did that, i programmed it in android studio and it had no errors. Please help, this is the Main activity named 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);
}
}
the XML goes like this
i want to move from this activity to the second ACTIVITY which is named Catalog java is
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>
the code is correct says android studio but when i run the adb on my phone it installs the app, everything goes fine but when i open the app it displays nothing but only the app icon and name at the top and nothing else what to do. please help
and here the main xml file also
<?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>
what to do
Upvotes: 0
Views: 46
Reputation: 3734
You have not overridden the onCreate(Bundle savedInstance)
method in class frontpagee
and have not called setContentView(R.layout...)
in it.
Upvotes: 2