Note that there are some explanatory texts on larger screens.

plurals
  1. POListener not firing in my activiy
    text
    copied!<p>I am trying to add a click listener and a long click listener to my Main Activity but its not firing.. below is my code, don't know why its not firing, can someone tell me what i am missing? Is it even possible to add a listener to the entire activity?</p> <pre><code>public class HomeFavesActivity extends Activity implements OnClickListener, OnLongClickListener{ private static final String TAG = "HomeFavesCatovoty"; private ArrayList&lt;Integer&gt; mIcons = new ArrayList&lt;Integer&gt;(); IconTray iconTray; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Log.v(TAG, "CREATED"); DataBaseManager db = new DataBaseManager(this); /*db.getWritableDatabase(); db.AddHomeScreenIcon(1); db.AddHomeScreenIcon(2); db.AddHomeScreenIcon(3); db.AddHomeScreenIcon(4); db.AddHomeScreenIcon(5); db.AddHomeScreenIcon(6); db.AddHomeScreenIcon(7);*/ getScreenIcons(db); } private void getScreenIcons(DataBaseManager db){ mIcons = db.getScreenIcons("TestScreenIcons"); Log.v(TAG, "List Length:"+ mIcons.size()); RelativeLayout rl = (RelativeLayout)findViewById(R.id.main); DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); int screenWidth = metrics.heightPixels; int screenHeight = metrics.widthPixels; iconTray = new IconTray(this, mIcons, null, screenWidth, screenHeight); /* RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(screenWidth, screenHeight); params.addRule(rl.CENTER_IN_PARENT); iconTray.setLayoutParams(params);*/ rl.addView(iconTray); rl.setOnLongClickListener(this); rl.setOnClickListener(this); } public void onClick() { // TODO Auto-generated method stub Toast.makeText(this, "woot", Toast.LENGTH_SHORT).show(); } public boolean onLongClick(View v) { // TODO Auto-generated method stub iconTray.longClickMode(); return false; } public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub iconTray.clickMode(); } } </code></pre> <p>OK so now the LongClick Listener works but when if add the line for the click it won't publish because it generates an error..</p> <p><strong>The method setOnClickListener(View.OnClickListener) in the type View is not applicable for the arguments (HomeFavesActivity)</strong></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload