开发者

Starting an activity when tapping on a widget

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜