Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hey guys....i have a menu with 3 image view that i set them as my buttons....now i want to when i click on each of them will going to another activity....by now....when i click on Enter button i move to the other activity and i havnt any problem with that....but i want when i clickng on About button the application inspiring me to the other activity that i created before....i dont know hot to do it?i dont know how to use this with if or else if command....can some one help me?these are the bunch of my codes....thanks :

Java
package my.book.namespace;
 
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
 
 
public class TheLastOfUsActivity extends Activity {
 
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
 
        ImageView myimg = (ImageView) findViewById(R.id.enter);
        myimg.setOnClickListener(new OnClickListener() {
 
            @Override
            public void onClick(View arg0) {
                startActivity(new Intent(TheLastOfUsActivity.this, one.class));
 
            }
        });
    }
}
Posted
Comments
iRakeshJha 28-Oct-14 14:56pm    
You want to come back to the 'TheLastOfUsActivity' from the 'one' activity?
Xiao Ling 28-Oct-14 20:31pm    
You should set click listener for every ImageView, not just the enter.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900