开发者

Starting an activity when tapping on a widget

开发者 https://www.devze.com 2023-04-12 22:36 出处:网络
I\'m developing an android widget and i would like to start a certain activity when i tap on a certain area of my widge开发者_运维技巧t, and another one when tapping somewhere else.

I'm developing an android widget and i would like to start a certain activity when i tap on a certain area of my widge开发者_运维技巧t, and another one when tapping somewhere else. How can i do this ?

Thank you!


Create 2 Linear Layouts in places wherever you want to touch, and let them be blank (No child).

Then add android:clickable = "true" in linear layouts. and now add clicklisteners to thes two layouts and start Activity..

Something like this..

LinearLayout layout = (LinearLayout)findViewById(R.id.layoutId);

layout.setOnClickListener(new OnClickListener(){

protected void onClick(View v){
//start Activity

}

});
0

精彩评论

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