I'm beginner in Android. I'm trying to make an app where when user tap on button he should go to another activity let say if user tap on button 1 he see new activity with information-A and if he press button 2 he see information-B in same activity he saw information A.
How can I set that.
If I am understanding your question correctly, here's a solution.
You can use the putExtras method of Intent to pass data in key/value pairs to the next activity.
Add the following to activity 1 layout:
<Button
android:id="#+id/btnA"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button A"
android:onClick="goToActivityFromButtonA" />
<Button
android:id="#+id/btnB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/btnA"
android:text="Button B"
android:onClick="goToActivityFromButtonB" />
Add the following methods to Activity 1:
public void goToActivityFromButtonA(View view) {
Intent intent = new Intent(this, ActivityTwo.class);
intent.putExtra("buttonData", "You clicked button A");
startActivity(intent);
}
public void goToActivityFromButtonB(View view) {
Intent intent = new Intent(this, ActivityTwo.class);
intent.putExtra("buttonData", "You clicked button B");
startActivity(intent);
}
Add the following to Activity 2 layout:
<TextView
android:id="#+id/txtText"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
Add the following to the onCreate method of activity 2:
TextView txtText = (TextView)findViewById(R.id.txtText);
txtText.setText(getIntent().getExtras().getString("buttonData"));
I just created a sample project for you:
https://drive.google.com/file/d/0B0S6sddMC_rMSUNieUxkR2lFRzQ/view?usp=sharing
you have first create ui for first activity like this
<RelativeLayout 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:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".FirstActivity" >
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="15dp"
android:layout_marginTop="77dp"
android:text="Button 1" />
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="110dp"
android:layout_marginLeft="38dp"
android:layout_toRightOf="#+id/button1"
android:text="Button 2" />
</RelativeLayout>
ui of second activity like this
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="second actvity" />
</LinearLayout>
activity first code where i set index with intent for both button click(you also put string double ling and message with intent)
package com.example.teststart;
import android.os.Bundle;
import android.os.Handler;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class FirstActivity extends Activity implements OnClickListener{
Button b1,b2;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_first);
b1=(Button)findViewById(R.id.button1);
b2=(Button)findViewById(R.id.button2);
b1.setOnClickListener(this);
b2.setOnClickListener(this);
}
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
int id=v.getId();
switch(id){
case R.id.button1:
Intent i1=new Intent(FirstActivity.this,secondactivity.class);
i1.putExtra("one", 1);
startActivity(i1);
break;
case R.id.button2:
Intent i2=new Intent(FirstActivity.this,secondactivity.class);
i2.putExtra("one", 2);
startActivity(i2);
break;
}
}
}
and second activity i get that integer value to identify which button is clicked and fire operation on that condition
package com.example.teststart;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class secondactivity extends Activity{
TextView tv;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.secondactvity);
tv=(TextView)findViewById(R.id.textView1);
Bundle extras = getIntent().getExtras();
int index = extras.getInt("one");
if(index==1){
tv.setText("nformation-A "+index);
}else if(index==2){
tv.setText("nformation-B "+index);
}
}
}
Related
hello friends today my question is about string_array.On my activity i created two buttons.Now on (strings.xml) i created string array name with two items and i have inserted some text as shown below.On each button click i would like to access each item individually.for example on button1 click show me first item and on button 2 click give me the 2nd item on.Can you please give me the code for button click as i have little idea on how to access item.I have created a textview activity to display my item with every click.my code is working fine till now but i need help with extra code that i have to add.Please help me .
// Button activity page
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
</ScrollView>
<Button
android:layout_height="wrap_content"
android:layout_marginTop="90dp"
android:layout_marginEnd="60dp"
android:layout_marginRight="50dp"
android:id="#+id/btn1"
android:layout_width="wrap_content"
android:text="#string/OKILA"
android:textSize="18sp"
android:textStyle="bold" />
<Button
android:id="#+id/button1"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_marginTop="160dp"
android:layout_marginRight="50dp"
android:text="1"
android:textSize="18sp"
android:textStyle="bold" />
</RelativeLayout>
//strings.xml
<string-array name="chapters">
<item>this is tes1</item>
<item>this is test2</item>
</string-array>
//main
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import org.w3c.dom.Text;
public class Lipok extends AppCompatActivity implements View.OnClickListener {
Toolbar mActionBarToolbar;
Button btnOne;
Button btnTwo;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lipok);
mActionBarToolbar=(Toolbar)findViewById(R.id.CHAPTERS);
setSupportActionBar(mActionBarToolbar);
getSupportActionBar().setTitle("CHAPTERS");
String[] chapters=getResources().getStringArray(R.array.chapters);
btnOne = findViewById(R.id.btn1);
btnTwo = findViewById(R.id.button1);
btnOne.setOnClickListener(this);
btnTwo.setOnClickListener(this);
}
#Override
public void onClick(View v) {
String text="";
switch(v.getId()){
case R.id.btn1 : {
text = getResources().getStringArray(R.array.chapters)[0];
break;
}
case R.id.button1 : {
text = getResources().getStringArray(R.array.chapters)[1];
break;
}
}
Intent intent = new Intent(Lipok.this,lipokchapters.class);
intent.putExtra("DATA", text);
startActivity(intent);
}
}
//textview activity page
package com.Aolai.temeshilai;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
public class lipokchapters extends AppCompatActivity {
TextView textView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lipokchapters);
textView=findViewById(R.id.textv);
String text= getIntent().getStringExtra("Data");
textView.setText(text);
}
}
Try this :
xml file
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
</ScrollView>
<Button
android:layout_height="wrap_content"
android:layout_marginTop="90dp"
android:layout_marginEnd="60dp"
android:layout_marginRight="50dp"
android:id="#+id/OKILA"
android:layout_width="wrap_content"
android:text="#string/OKILA"
android:textSize="18sp"
android:textStyle="bold" />
<Button
android:id="#+id/button1"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_marginTop="160dp"
android:layout_marginRight="50dp"
android:text="1"
android:textSize="18sp"
android:textStyle="bold" />
</RelativeLayout>
strings.xml
<string-array name="chapters">
<item>this is tes1</item>
<item>this is test2</item>
</string-array>
Main Class
public class Lipok extends AppCompatActivity implements View.OnClickListener {
Toolbar mActionBarToolbar;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lipok);
mActionBarToolbar=(Toolbar)findViewById(R.id.CHAPTERS);
setSupportActionBar(mActionBarToolbar);
getSupportActionBar().setTitle("CHAPTERS");
}
#Override
public void onClick(View v) {
String text="";
switch(v.getId()){
case R.id.OKILA : {
text = getResources().getStringArray(R.array.testArray)[0];
break;
}
case R.id.button1 : {
text = getResources().getStringArray(R.array.testArray)[1];
break;
}
}
Toast.makeText(this, text, Toast.LENGTH_LONG).show();
Intent intent = new Intent(this, YOUR_ACTIVITY_NAME.class);
intent.putExtra("DATA", text);
startActivity(intent);
// Or else you can do whatever you want to do here with that text
}
}
Then in your other activity
String data = getIntent().getStringExtra("DATA");
YOUR_TEXTVIEW_NAME.setText(data);
This is basics of Android so before answering I suggest you to go
through basic tutorials before posting on Stackoberflow.
Now,
Here is how you can access the items from your string_array.
String[] chapters= getResources().getStringArray(R.array.chapters);
Now,here is pseudo code that might help you.
btn1.setOnClickListener(
your_text_view.setText(chapters[0])
)
//Here 0 means your first item, likewise you can access items by their index in
array
I have two rather basic questions I believe which needs answering:
1) When I run my emulator on the home screen my SignIn button is unresponsive and I am unsure why as I have tried alternative methods but whenever I click nothing happens and no error is showing. Code is shown below:
package com.techblogon.loginexample;
import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class HomeActivity extends Activity
{
Button btnSignIn,btnSignUp;
LoginDataBaseAdapter loginDataBaseAdapter;
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// create a instance of SQLite Database
loginDataBaseAdapter=new LoginDataBaseAdapter(this);
loginDataBaseAdapter=loginDataBaseAdapter.open();
// Get The Reference Of Buttons
btnSignIn=(Button)findViewById(R.id.buttonSignIN);
btnSignUp=(Button)findViewById(R.id.buttonSignUP);
// Set OnClick Listener on SignUp button
btnSignUp.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
/// Create Intent for SignUpActivity and Start The Activity
Intent intentSignUP=new Intent(getApplicationContext(),SignUPActivity.class);
startActivity(intentSignUP);
}
});
}
// Method to handleClick Event of Sign In Button
public void signIn(View V)
{
final Dialog dialog = new Dialog(HomeActivity.this);
dialog.setContentView(R.layout.login);
dialog.setTitle("Login");
final EditText editTextUserName=(EditText)dialog.findViewById(R.id.editTextUserNameToLogin);
final EditText editTextPassword=(EditText)dialog.findViewById(R.id.editTextPasswordToLogin);
Button btnSignIn=(Button)dialog.findViewById(R.id.buttonSignIN);
// Set On ClickListener
btnSignIn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// get The User name and Password
String userName=editTextUserName.getText().toString();
String password=editTextPassword.getText().toString();
// fetch the Password form database for respective user name
String storedPassword=loginDataBaseAdapter.getSinlgeEntry(userName);
// check if the Stored password matches with Password entered by user
if(password.equals(storedPassword))
{
Toast.makeText(HomeActivity.this, "Welcome", Toast.LENGTH_LONG).show();
dialog.dismiss();
Intent ii=new Intent(HomeActivity.this,MainMenu.class);
startActivity(ii);
}
else
{
Toast.makeText(HomeActivity.this, "User Name or Password does not match", Toast.LENGTH_LONG).show();
}
}
});
dialog.show();
}
#Override
protected void onDestroy() {
super.onDestroy();
// Close The Database
loginDataBaseAdapter.close();
}
}
Could somebody provide me with the best sqlite database viewer for eclipse, I am looking to view the records of the database I have created on my emulator
My XML is as follows
<LinearLayout 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:gravity="center_vertical"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/picture" />
<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Hello, Welcome"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="#+id/buttonSignIN"
android:layout_width="fill_parent"
android:layout_height="70dp"
android:text="Sign In" />
<Button
android:id="#+id/buttonSignUP"
android:layout_width="fill_parent"
android:layout_height="70dp"
android:text="Sign Up" />
</LinearLayout>
you are missing an attribute in xml for buttonSignIN button
android:onClick="signIn"
Try this,
<Button
android:id="#+id/buttonSignIN"
android:layout_width="fill_parent"
android:layout_height="70dp"
android:onClick="signIn"
android:text="Sign In" />
You need to understand the difference between setting clickListener in java code and setting a attribute from xml for the button click. These are two different ways in which you could achieve click events for any element.
I'm just learning android here, and Java to be honest. I'm just trying to switch to a different activity via a button click, however, it keeps crashing. It crashes when I click the button and go to make the switch. Can someone please help me figure where I'm going wrong?
First Activity:
package com.example.killacatoe;
import android.os.Bundle;
import android.app.Activity;
import android.view.*;
import android.widget.*;
import android.content.*;
public class TicTacToe extends Activity {//Start TicTactToe Class
//CONSTANTS
//Variables
Button mainButton;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tic_tac_toe);
mainButton = (Button) findViewById(R.id.bPlayNow);
mainButton.setOnClickListener(new View.OnClickListener(){
public void onClick(View v) {
// TODO Auto-generated method stub
Intent i = new Intent(getApplicationContext(), playerMenu.class);
startActivity(i);
}
});
}
}//End TicTacToe Class
Activity I'm jumping to:
package com.example.killacatoe;
import android.os.Bundle;
import android.app.Activity;
import android.view.*;
import android.widget.*;
public class playerMenu extends Activity {
Button bOnePlayer, bTwoPlayer;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.player);
bOnePlayer = (Button) findViewById(R.id.bOnePlayer);
bOnePlayer.setOnClickListener(new View.OnClickListener(){
public void onClick(View v) {
// TODO Auto-generated method stub
}
});
bTwoPlayer = (Button) findViewById(R.id.bTwoPlayer);
bTwoPlayer.setOnClickListener(new View.OnClickListener(){
public void onClick(View v) {
// TODO Auto-generated method stub
}
});
}
}
Here is the XML for the first activity:
<RelativeLayout 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:background="#000000"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".TicTacToe" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:textSize="50dp"
android:text="Welcome to \nTic-Tac-Toe"
android:textColor="#FFFFFF" />
<Button
android:id="#+id/bPlayNow"
android:layout_width="150dp"
android:layout_height="100dp"
android:layout_below="#+id/textView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="137dp"
android:textSize="34dp"
android:text="Play now!" />
</RelativeLayout>
XML for the second activity:
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin" >
/>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_x="78dp"
android:layout_y="30dp"
android:text="GAME MODE"
android:textColor="#FFFFFF"
android:textSize="50dp" />
<Button
android:id="#+id/bOnePlayer"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_x="25dp"
android:layout_y="160dp"
android:text="Single Player"
android:textSize="25dp" />
<Button
android:id="#+id/bTwoPlayer"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_x="25dp"
android:layout_y="220dp"
android:text="Two Player"
android:textSize="25dp" />
</AbsoluteLayout>
For starting a new activity, it is necessary to add it in the manifest file.
<application >
...
<activity
android:name="com.example.killacatoe.playerMenu" >
</activity>
</application>
then in onCreate(), for starting a new activity when the button is pressed, you can do:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.player);
bOnePlayer = (Button) findViewById(R.id.bOnePlayer);
bOnePlayer.setOnClickListener(new View.OnClickListener(){
public void onClick(View v) {
Intent intent = new Intent(TicTacToe.this, playerMenu.class);
startActivity(intent);
}
});
}
Make sure that you define playerMenu in the AndroidManifest file.
<application ... >
...
<activity
android:name="com.example.killacatoe.playerMenu" >
</activity>
</application>
Check this page for more information
http://developer.android.com/training/basics/firstapp/starting-activity.html
Are you sure that you have register your PlayerMenu activity in AndroidManifest.xml ?
...
please paste the error log.
use this code in your first Activity to jump to another
onClick(View v){
Intent ps = new Intent (TicTacToe.this,
PlayerMenu.class);
startActivity(ps);
}
Manifest File :
<Activity
android:name="com.example.killacatoe.TicTacToe">
</Activity>
users have an activity with an edittext and a button.
in the edittext they have to insert their login ID. and press go to display a other activity with webview loading the right site.
an example. this is the link i want users to visit . www.example.com/time/id=1/type=student
if sombody enters a 2 in the edittext it wil open the times for student id 2 and so on.
this is what i have.
LOGIN
package com.beter;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.app.Activity;
import android.content.Intent;
public class LoginActivity extends Activity {
Button go_btn;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
go_btn = (Button) findViewById(R.id.go_btn);
go_btn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Intent myIntent = new Intent(LoginActivity.this, WebActivity.class);
LoginActivity.this.startActivity(myIntent);
}
});
}
and the layout
<RelativeLayout 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" >
<EditText
android:id="#+id/idfield"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:ems="10"
android:hint="#string/id"
android:inputType="number" >
<requestFocus />
</EditText>
<Button
android:id="#+id/go_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_toRightOf="#+id/idfield"
android:text="#string/login" />
The Webview Activity
package com.beter;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
public class WebActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webview);
WebView webview = new WebView(this);
setContentView(webview);
webview.loadUrl("http://roosters.gepro-osi.nl/roosters/rooster.php?wijzigingen=1&leerling=116277&type=Leerlingrooster&afdeling=12-13_OVERIG&school=905");
}
}
and again the layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<WebView
android:id="#+id/webView1"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
How do i make the user input. display the good webview. ?
First of all get a reference to your edittext in your Login Activity as
go_btn = (Button) findViewById(R.id.go_btn);
ed_txt = (EditText)findViewById(R.id.youredittextid);
The change your onClick to
public void onClick(View v) {
Intent myIntent = new Intent(LoginActivity.this, WebActivity.class);
myIntent.putExtra("id", ed_txt.getText());
LoginActivity.this.startActivity(myIntent);
}
Then retrive this id in your WebActivity onCreate as
String id = getIntent().getExtras().getString("id");
Then your url will be
String myURL = "www.example.com/time/id="+id+"/type=student";
This is the java code and xml file for a program I am writing, and it force closes whenever i try to invoke the plusCalc button in-program. Could someone please tell me why?
Thank you!
Java file:
package org.example.knittingframe;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.content.Intent;
public class KnittingFrame extends Activity implements OnClickListener {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
View plusCalc = findViewById(R.id.plus_calc_button);
plusCalc.setOnClickListener(this);
View exitbutton = findViewById(R.id.exit_button);
exitbutton.setOnClickListener(this);
}
public void onClick(View v) {
switch(v.getId()) {
case R.id.plus_calc_button:
startPlusCalc();
break;
case R.id.exit_button:
finish();
break;
}
}
public void startPlusCalc() {
Intent i = new Intent(this, PlusCalc.class);
startActivity(i);
}
}
Here is the XML file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:text="#string/main_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="25dip"
android:textSize="24.5sp" />
<Button
android:id="#+id/plus_calc_button"
android:layout_width="300px"
android:layout_height="wrap_content"
android:text="#string/plusCalc_label"
android:layout_gravity="center" />
<Button
android:id="#+id/exit_button"
android:layout_width="300px"
android:layout_height="wrap_content"
android:text="Exit"
android:layout_gravity="center" />
</LinearLayout>
Without the stack trace it appears that the problem is with declaring the PlusCalc.class class in the App Manifest file, because as you say, the error only appears when you click on the PlusCalc button.
If this doesn't help please post the stack trace.