Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

test: Reply
 
LinkBack Thread Tools
Old November 19th, 2010, 01:39 AM   #1 (permalink)
New Member
Thread Author (OP)
 
Join Date: Nov 2010
Posts: 1
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default How to go to new screen ..

I am new to android development programming. So i started few weeks ago and i am stuck in a trouble.. I am trying to make a simple program which have two screen ..the first screen (main.xml) have two bottun and one text view and one edit text when some one input their name in the edit text and click the first button (ButtonClick) it shows hello there and the name inputed form edit text. then when cock the second button (ButtonOk) it goes to second screen showing a message "successful" in a text view.. but when i click the ButtonOk nothing happens... can any one help.. my coded are below:

The main java class:

package com.example.helloshamik;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class hellothere extends Activity {
Button ButtonClick, ButtonOk;
TextView TextShow, TextFinal;
EditText Name;
/** Called when the activity is first created. */
@Override

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ButtonClick = (Button)findViewById(R.id.ButtonClick);
ButtonOk = (Button)findViewById(R.id.ButtonOk);
TextShow = (TextView)findViewById(R.id.TextShow);
TextFinal = (TextView)findViewById(R.id.TextFinal);
Name = (EditText) findViewById(R.id.Name);

//Initialize textview

TextShow.setText("Click the 'Click it' Botton");

ButtonClick.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
TextFinal.setText("Hello There "+ Name.getText());
}
});
ButtonOk.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent myIntent = new Intent(v.getContext(), screen1.class);
startActivityForResult(myIntent, 0);
}
});

}
}

the second java class:


package com.example.helloshamik;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class screen1 extends Activity {
TextView TextSucess;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextSucess = (TextView)findViewById(R.id.TextSuccess);
TextSucess.setText("Sucessful");
}
}

FYI I have added activity in mainfest.xml and done other stuff too..

Advertisements
macbeth4397 is offline  
Reply With Quote
sponsored links
Old November 21st, 2010, 03:43 AM   #2 (permalink)
New Member
 
Join Date: Nov 2010
Posts: 1
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default

try with this example:


Code:
public class one extends Activity
{
      Button goTO;

     public void onCreate(Bundle savedInstanceState)
     {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.layONE);
         
         goTO = (Button)this.findViewById(R.id.buttongoTO);
         goTO.setOnClickListener(new View.OnClickListener(){
            public void onClick(View v)
            {
                Intent i = new Intent(one.this, secondCLASS.class);
                startActivity(i);
            }
        });
}
I hope to give u a hand! XD
(sorry for my bad english)
UniversalMind88 is offline  
Reply With Quote
Reply


Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 03:05 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.