Question

I am working on an application where I need to go to the next Screen form the Main Actvity when I Click on the Image Button of the Main Activity Screen.

I had searched a bit on Net regarding this and found something like the OnClickListener method. I am still stuck for what exactly I want to do actually.

Can anyone please tell me how to do the same.

Thanks, david

Was it helpful?

Solution

yourButton.setOnClickListener(){    
    public void onCLick(View v){
      Intent i=new Intent(
             YouCurrentClass.this,
             NameOfJaveInWhichYouWantToMove.class);
      startActivity(i);
    }
};

OTHER TIPS

if you have your view as xml layout in your project then what you want to do is

onTouch or onClick or whatever triggers your change view

setContentView(R.layout.layoutYouWantToDisplay);

or other method of loading all pages at start and after the application simply just manage the visibility layouts. Try to research the ViewFlipper is interresting.

Try this ...it will help you for sure

public class your_file_name extends Activity implements OnClickListener {

public ImageButton any_name;

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

    any_name = (ImageButton) findViewById(R.id.given id<check in your layout for it> );
any_name. setOnClickListener(){    
public void onCLick(View v){
  Intent myintent=new Intent(your_file_name.this, next_desired_class.class);
  startActivityforresult(myintent,100);
}
};
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top