How To Start Activity By Click Any Where On Row
Solution 1:
just bind a click event for each linearLayout container : picture_part, video_part, sms_call_part...
for example :
LinearLayoutmenu_photos= (LinearLayout )findViewById(R.id.picture_part);
menu_photos.setOnClickListener(newOnClickListener() {
@OverridepublicvoidonClick(View v) {
Intentpicture_intent=newIntent(CurrentActivity.this,PictureActivity.class);
startActivity(picture_intent );
}
});
use the same method for other items.
Solution 2:
you can set the onClick
property for each view that you want to click on with a corresponding method.
for example:
android:onClick="viewOnClickMethod"
and in your Activity
class define the method:
publicvoidviewOnClickMethod(View v){
//from here start any activity you want
}
for view that are not designed to be clickable you will have to set the:
android:clickable="true"
property as well.
Solution 3:
You should have used listView and OnItemSelectedListener.
This way you could have avoided writing so much XML and also avoid the need to set a listener for each of the rows.
In the listener, check which item was selected and start the activity you wish, by using startActivity(). if the activity belongs to your app, put its info in the manifest file.
Also, you could have used the action bar instead of the customized upper bar.
Post a Comment for "How To Start Activity By Click Any Where On Row"