INTENT HELP

+1 david owodunni · November 20, 2015
Need help for my intent.... the thing is when i click the the start button the app is suppose to move to the next activity.. pls help



this the mainActivity.java code

package com.example.dave.myapplication;

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

public class MainActivity extends ActionBarActivity {

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

public void onClick(View view){
Intent i = new Intent(this, Main2Activity.class);
startActivity(i);
}

@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);
}
}

  
this is the .xml file for the start page






this the activity  it is suppose to switch to..
java code

package com.example.dave.myapplication;

import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.Toast;

public class Main2Activity extends ActionBarActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
String[] Menu = {"ERRORS", "SLOPE", "INTERCEPT", "OTHER CALCULATIONS", "DEFINITIONS", "Ă„BOUT"};
ListAdapter mainmenuAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, Menu);
ListView menulistview = (ListView) findViewById(R.id.menulistView);
menulistview.setAdapter(mainmenuAdapter);

menulistview.setOnItemClickListener(
new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView parent, View view, int position, long id) {
String Menu = String.valueOf(parent.getItemIdAtPosition(position));
Toast.makeText(Main2Activity.this, Menu, Toast.LENGTH_SHORT).show();
}
}

);

}
@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);
}
}


 and  this is the .xml code













help plssss............
dave frm Nigeria

Post a Reply

Replies

Oldest  Newest  Rating
0 Rutaba Niazi · November 22, 2015
what error does it gives in the logcat??
  • 1

Java / Android Development

107,072 followers
About

Very popular language used to create desktop applications, website applets, and Android apps.

Links
Moderators
Bucky Roberts Administrator