button onClick listener

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

button onClick listener

Postby vallis » Sun Nov 09, 2008 5:57 pm

Hey, I hope this is the right place for this post
I have a button in my app that I need to watch for click events.
When it's clicked I need to call a method that takes a Context and a String as its parameters.
The problem is that I cannot access context from within the inner class OnClickListener

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. final Button filterButton = (Button) findViewById(R.id.filtered);
  3.  
  4.         filterButton.setOnClickListener(new View.OnClickListener()
  5.  
  6.         {
  7.  
  8.                 public void onClick(View v)
  9.  
  10.                 {
  11.  
  12.                 listType = "filtered";
  13.  
  14.                 createList(a context, a string)     //createList takes a context and a string as its params
  15.  
  16.             }
  17.  
  18.         });
  19.  
  20.  
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


Does anyone know of a way to do this?
Thanks in advance.
Cheers,
V.
vallis
Junior Developer
Junior Developer
 
Posts: 23
Joined: Sat Oct 11, 2008 12:52 pm
Location: Scotland

Top

Postby vallis » Sun Nov 09, 2008 6:13 pm

Cancel that!
I found a way to make createList() work without requiring a contex to be passed to it.

Sorry for wasting a thread.
Cheers,
V.
vallis
Junior Developer
Junior Developer
 
Posts: 23
Joined: Sat Oct 11, 2008 12:52 pm
Location: Scotland

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Exabot [Bot] and 6 guests