
November 2nd, 2012, 08:00 AM
|
|
Registered User
|
|
Join Date: Aug 2011
Posts: 18
Time spent in forums: 2 h 24 m 17 sec
Reputation Power: 0
|
|
|
Android click & longclick
I keep getting an error on the onLongClick part of this function. I want the click to take the user to phone dialer (this works), but when adding the onLongClick to go to the dialer settings activity I am getting errors. Ive tried with a public void and public boolean, but eclipse still has error, help appreciated.
Code:
Button button1 = (Button) findViewById(R.id.button1);
button1.setText(phonelbl[0]);
button1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
launchDialer(phone[1]);
}
});
// button1.setLongClickable(true);
button1.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
//public void onLongClick(View v) {
Intent i = new Intent(MainActivity.this, AddDiner.class);
startActivity(i);
}
});
I fixed it. I needed return true; in the onLongClick function
|