开发者

Switching over to next Screen from the main Activity by clicking on the Button

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开发者_如何学C still stuck for what exactly I want to do actually.

Can anyone please tell me how to do the same.

Thanks, david


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


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜