I was working for my college project, for a typical user interaction app . I have implemented a button that upon a long click will open up a floating contextual menu . Is there any way to open this menu upon a single click .I have checked around the web but I couldn't solve this issue . thank your for your time.
public class MainActivity extends ActionBarActivity {
Button b1;
RelativeLayout ourlayout;
String s1="@string/menu_add";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
b1 = (Button)findViewById(R.id.button1);
registerForContextMenu(b1);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
//////////////////////////////////////////////////////////////
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
// TODO Auto-generated method stub
super.onCreateContextMenu(menu, v, menuInfo);
getMenuInflater().inflate(R.menu.net, menu);
menu.setHeaderTitle("Select your service provider");
}
@Override
public boolean onContextItemSelected(MenuItem item) {
switch (item.getItemId()) {
}
return super.onOptionsItemSelected(item);
}
}