setOnItemClickListener for gallery does not work?

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

setOnItemClickListener for gallery does not work?

Postby LittleAndroid » Fri Jan 09, 2009 7:01 am

I want to make textview slide when I click one picture in the gallery,but it does not work.

my code:


Code: Select all
    public class Gallery1 extends Activity {
    private ViewFlipper mFlipper;
    private Context context;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.gallery_1);
       
        // Reference the Gallery view
        Gallery g = (Gallery) findViewById(R.id.gallery);
       
       // Set the adapter to our custom adapter (below)
        g.setAdapter(new ImageAdapter(this));
     
        g.setOnItemClickListener(new OnItemClickListener() {
                public void onItemClick(AdapterView parent, View v, int position, long id) {
               
                mFlipper = ((ViewFlipper)findViewById(R.id.flipper));
               
                mFlipper.setInAnimation(AnimationUtils.loadAnimation(context,
                        R.anim.push_left_in));
                mFlipper.setOutAnimation(AnimationUtils.loadAnimation(context,
                        R.anim.push_left_out));
                mFlipper.startFlipping();  }
        });
             
        // We also want to show context menu for longpressed items in the gallery
        registerForContextMenu(g);
       
    }


I think the problem is context.But I changed it to the following:


[img]E:problem[/img]



plz tel me
thx in andvance

PS:I got a little bit difficult in inserting a picture ╯﹏╰
Attachments
未命名.JPG
未命名.JPG (42.45 KiB) Viewed 730 times
LittleAndroid
Freshman
Freshman
 
Posts: 3
Joined: Tue Jan 06, 2009 4:12 am

Top

Postby LittleAndroid » Fri Jan 09, 2009 8:48 am

i solve it. i change context into Gallery1.this.that is ok. O(∩_∩)O
LittleAndroid
Freshman
Freshman
 
Posts: 3
Joined: Tue Jan 06, 2009 4:12 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 6 guests