开发者

Android - swipe screen right and create popup

I'm beginner on android development i have two question 1) i'm trying to create popup, when the user tap on some gallery image by setOnItemClickListener() method. i've seen here some sample code and it's not working for me, can someone tell me what's the problem?

public void onItemClick(AdapterView 开发者_StackOverflow中文版parent, View v, int position, long id) {
    if (position == 1){
        createPopUpWindow();
    }
}

private void createPopUpWindow(){
    LayoutInflater inflater = (LayoutInflater)
    this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View layout = inflater.inflate(R.id.imageView1,
    (ViewGroup) findViewById(R.layout.popup_example));
    pw = new PopupWindow(layout, 300, 470, true);
    pw.showAtLocation(layout, Gravity.CENTER, 0, 0);
}

2) can i use the horizontal view represent by gallery, to make clean swipe screen right a generic view object like any layout.xml instead of images, some sample code will be helpful?? Thanks, David


This is not really how you should display a popup. Here is a guide to do what you want, in the good way.

For your second question, Gallery is not really intend to do this. Instead, there is two possibility, use a ViewFlipper with this example, or, much better, the ViewPager which is in the compatibility package, it works on all version of Android after 1.5, and use the same mechanism than the Gallery, with a BaseAdapter.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜