Search code examples
androidbuttondetailsviewdetailview

When click Button go to DetailView


Can someone help me?: I have two diffrent buttons and when I press Button 1 I want to open the DetailView with Information1. When I press Button 2 I want to open the DetailView with Information2 Here is the Tutorial I choosen for the ListView and the DetailView: http://www.raywenderlich.com/5527/getting-started-with-android-development

With the ListView it works perfect, but how to do this with two buttons?

Thanks for help :)


Solution

  • Simply intent to that activity on button click

    Button1.setOnClickListener(new OnClickListener() {
    
    public void onClick(View v) {
    
     Intent i = new Intent(MainActivity.this,DetailActivity.class);
     i.putExtra("Detail1","Detail 1");
     startActivity(i);  
    
       }
    });
    
    
       Button2.setOnClickListener(new OnClickListener() {
    
        public void onClick(View v) {
    
         Intent i = new Intent(MainActivity.this,DetailActivity.class);
         i.putExtra("Detail2","Detail 2");
         startActivity(i);  
    
           }
        });