How can I see a value on the spinner? - android

My question is: I am using spinner on my android app. However, I can't see the default value shown on the spinner, at all. I can select elements but I can't see any text on the spinner. It seems like the value is hidden and doesn't show anything, just the spinner itself and drop down arrow.
mDbHelper = new DbAdapter(this);
mDbHelper.open();
cursor = mDbHelper.fetchAllBusinessCards();
startManagingCursor(cursor);
contactSpinner = (Spinner) findViewById(R.id.contactSpinner);
contactSpinner.setOnItemSelectedListener(new MyOnItemSelectedListener());
fillData();
}
public class MyOnItemSelectedListener implements OnItemSelectedListener {
public void onItemSelected(AdapterView<?> parent,
View view, int pos, long id) {
Toast.makeText(parent.getContext(), "The planet is " +
parent.getItemAtPosition(pos).toString(), Toast.LENGTH_LONG).show();
}
public void onNothingSelected(AdapterView parent) {
// Do nothing.
}
}
private void fillData() {
/*Create an array to specify the fields we want to display in the list (only the 'colourName' column in this case) */
String[] from = new String[]{DbAdapter.getKeyTitle() };
/* and an array of the fields we want to bind those fields to (in this case just the textView 'tvDBViewRow' from our new db_view_row.xml layout above) */
int[] to = new int[]{R.id.tvDBViewRow};
/* Now create a simple cursor adapter.. */
SimpleCursorAdapter colourAdapter =
new SimpleCursorAdapter(this,R.layout.db_view_row, cursor, from, to);
/* and assign it to our Spinner widget */
contactSpinner.setAdapter(colourAdapter);
//contactSpinner.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
contactSpinner.setSelection(0);
}
#Override
protected void onDestroy() {
super.onDestroy();
if (mDbHelper != null) {
mDbHelper.close();
}
}
}

You can call spinner.setSelection to set the current state of the
spinner to whatever you want. And that definitely works
spinner.setSelection(0);
but you must also call
setDropDownViewResource()
let say
adapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);

Related

Loading two SQL columns into a listview but only need to display the first column Android

I am using an sqllite database to store two columns which are phonename and phonenumber. I am using an arrayList to iterate through the data and display the phonename in a listview which is working, but I also need to iterate through the phonenumber column under the same listview as well. I only need the phonename to be showing in the listview.
This is for when the user has selected the item in the listview, it shows the selected phonename and phonenumber, which at the moment it is only currently showing the phonename and showing blank for phonenumber for obvious reasons.
DataDBAdapter
public long insert(String phonename, String phonenumber)
{
ContentValues cv = new ContentValues();
cv.put(COl_MYTABLE_PHONENAME,phonename);
cv.put(COL_MYTABLE_PHONENUMBER,phonenumber);
return mDB.insert(TBL_MYTABLE,null,cv);
}
//---------------------------------------------------------------------------
// Iterating through the database
//---------------------------------------------------------------------------
public ArrayList<String> getAllRowsAsList()
{
Cursor csr = mDB.query(TBL_MYTABLE,null,null,null,null,null,null);
ArrayList<String> rv = new ArrayList<>();
while (csr.moveToNext())
{
rv.add(csr.getString(csr.getColumnIndex(COl_MYTABLE_PHONENAME)));
}
return rv;
}
SelectModemFragment
private void manageListView(Context context)
{
thelist = dbHelper.getAllRowsAsList(); // Extract the list, just the phone names
// Only setup the adapter and the ListView if the adapter hasn't been setup
if(arrayAdapter == null)
{
// Instantiate the adapter
arrayAdapter = new ArrayAdapter<>(context,android.R.layout.simple_list_item_1,thelist); //<<<<<<<<<< list included
display_contacts1.setAdapter(arrayAdapter); //<<<<<<<<<< Tie the adpater to the ListView
// Set the ListViews OnItemClick Listener
display_contacts1.setOnItemClickListener(new AdapterView.OnItemClickListener()
{
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
String namedisplay = arrayAdapter.getItem(position); //<<<<<<<<<< this gets the phone name
namedisplay = arrayAdapter.getItem(position);
Toast.makeText(view.getContext(), namedisplay + " Selected for Communication", Toast.LENGTH_SHORT).show();
Toast.makeText(view.getContext(), phoneNo, Toast.LENGTH_SHORT).show();
}
});
}
Issue
using ArrayAdapter only allows a a single item to be passed, thus unless you resort to complicated/messy/inefficient methods ArrayAdapter is only really suitable for a single value.
Fix
You could use an ArrayList where your_object has members for all the required values. i.e phonenumber and phonename. Noting that unless you use a Custom Adapter that you should override the the toString method to extract the data that you want to be displayed, as that is what a standard ArrayAdapter uses.
Alternative (use a CursorAdapter)
An alternative would be to use a Cursor Adapter (e.g. SimpleCursorAdapter), you can then return the Cursor and use it directly. However, a CursorAdapter REQUIRES a column specifically name _id (BaseColumns._ID can be used).
One of the clear advantages of a Cursor adapter is the the 4th paremmter passed to the onItemClick/onItemLongClick is the id of the row (if used correctly) allowing a single value to then get/update/delete/pass the respective selected row.
As such I'd recommend a Cursor Adapter for a ListView and hence the more comprehensive answer.
You may think I don;t have such a column. However, you can use the normally hidden rowid column and dynamically create a column named _id.
You could have a method, in the database helper (DataDBAdapter) such as :-
public Cursor getAllRowsAsCursor()
{
String[] columns = new String[]{"rowid AS " + BaseColumns._ID,"*"}
return = mDB.query(TBL_MYTABLE,null,null,null,null,null,null)
}
The ManageList method could then be :-
private void manageListView(Context context) {
myCursor = dbhelper.getAllRowsAsCursor();
// Only setup the adapter and the ListView if the adapter hasn't been setup
if(arrayAdapter == null)
{
// Instantiate the adapter
arrayAdapter = new SimpleCursorAdapter(context,android.R.layout.simple_list_item_1,myCursor,new String[]{DataAdapter.COl_MYTABLE_PHONENAME},newint[]{android.R.id.text1},0);
display_contacts1.setAdapter(arrayAdapter); //<<<<<<<<<< Tie the adpater to the ListView
// Set the ListViews OnItemClick Listener
display_contacts1.setOnItemClickListener(new AdapterView.OnItemClickListener()
{
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
String namedisplay = arrayAdapter.getItem(position); //<<<<<<<<<< this gets the phone name
String phonenumber = myCursor,getString(myCursor.getColumnIndex(DataAdapter.COL_MYTABLE_PHONENUMBER);
Toast.makeText(view.getContext(), namedisplay + " Selected for Communication", Toast.LENGTH_SHORT).show();
Toast.makeText(view.getContext(), phonenumber, Toast.LENGTH_SHORT).show();
}
});
} else {
arrayAdapter.swapCursor(myCursor);
}
Notes
MyCursor would be declared as a class variable e.g. Cursor MyCursor;
Instaed of
ArrayAdapter<String> arrayAdapter; you would have
SimpleCursorAdapter arrayAdapter;
The above is in-principle code and has not been tested, so there may be errors and/or omissions.
Working Example
The following is the code based upon the code from the previous question asked (which this appears to follow on from). It has two ListViews the old and a new one that uses a SimpleCursorAdapter. Clicking an item display phone number and also id. Lon Clicking an Item deletes that item (refreshing both ListViews).
DataDBAdapter.java has two new methods (so add these) :-
//<<<<<<<<<< ADDED
public Cursor getAllRowsAsCursor() {
return mDB.query(TBL_MYTABLE,null,null,null,null,null,null);
}
public int delete(long id) {
String whereclause = COL_MYTABLE_ID + "=?";
String[] whereargs = new String[]{String.valueOf(id)};
return mDB.delete(TBL_MYTABLE,whereclause,whereargs);
}
SelectModemFragment.java is now :-
public class SelectModemFragment extends Fragment {
private SelectModemViewModel mViewModel;
ListView display_contacts1;
ArrayAdapter<String> arrayAdapter;
ArrayList<String> thelist;
DataDBAdapter dbhelper;
//<<<<<<<<<< ADDED
ListView display_contacts2;
SimpleCursorAdapter sca;
Cursor MyCursor;
public static SelectModemFragment newInstance() {
return new SelectModemFragment();
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.select_modem_fragment, container, false);
display_contacts1 = view.findViewById(R.id.lv001); //<<<<<<<<<< top listview ArrayAdapter<String>
display_contacts2 = view.findViewById(R.id.lv002);
dbhelper = new DataDBAdapter(view.getContext());
AddSomeData();
manageListView(view.getContext());
manageListView2();
return view;
}
#Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mViewModel = ViewModelProviders.of(this).get(SelectModemViewModel.class);
// TODO: Use the ViewModel
}
//Sets up the ListView if not already setup
private void manageListView(Context context) {
thelist = dbhelper.getAllRowsAsList(); //<<<<<<<<<< extract the list (just the phone names) from the database
// Only setup the adapter and the ListView if the adapter hasn't been setup
if (arrayAdapter == null) {
// Instantiate the adapter
arrayAdapter = new ArrayAdapter<>(context,android.R.layout.simple_list_item_1,thelist); //<<<<<<<<<< list included
display_contacts1.setAdapter(arrayAdapter); //<<<<<<<<<< Tie the adpater to the ListView
// Set the ListViews OnItemClick Listener
display_contacts1.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String name = arrayAdapter.getItem(position); //<<<<<<<<<< this gets the phone name
Toast.makeText(view.getContext(),"You clicked the phone named " + name,Toast.LENGTH_SHORT).show();
}
});
} else {
//<<<<<<<<<< MODIFIED to cope with changes (needs to rebuild the array within the adpater)
arrayAdapter.clear();
for (String s: thelist) {
arrayAdapter.add(s);
}
arrayAdapter.notifyDataSetChanged();
}
}
//<<<<<<<<<< ADDED FOR CursorAdapter
private void manageListView2() {
MyCursor = dbhelper.getAllRowsAsCursor();
if (sca == null) {
sca = new SimpleCursorAdapter(
getContext(),
android.R.layout.simple_list_item_1,
MyCursor,
new String[]{DataDBAdapter.COl_MYTABLE_PHONENAME},
new int[]{android.R.id.text1},
0
);
display_contacts2.setAdapter(sca);
display_contacts2.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(view.getContext(),
"You Clicked the phone name " +
MyCursor.getString(MyCursor.getColumnIndex(DataDBAdapter.COl_MYTABLE_PHONENAME)) +
". The phonenumber is " +
MyCursor.getString(MyCursor.getColumnIndex(DataDBAdapter.COL_MYTABLE_PHONENUMBER)) +
". The ID (as passed) is " + String.valueOf(id) +
". The ID (from Cursor) is " + String.valueOf(MyCursor.getLong(MyCursor.getColumnIndex(DataDBAdapter.COL_MYTABLE_ID)))
,
Toast.LENGTH_SHORT).show();
}
});
//<<<<<<<<<< EXTRA delete row on long click
display_contacts2.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
#Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
dbhelper.delete(id);
manageListView2();
manageListView(getContext());
return true;
}
});
} else {
sca.swapCursor(MyCursor);
}
}
// Add some testing data (only if none already exists)
private void AddSomeData() {
if (DatabaseUtils.queryNumEntries(dbhelper.getWritableDatabase(),DataDBAdapter.TBL_MYTABLE) < 1) {
dbhelper.insert("Phone 1", "0000000000");
dbhelper.insert("Phone 2", "1111111111");
}
}
#Override
public void onResume() {
super.onResume();
manageListView2();
manageListView(getContext());
}
#Override
public void onDetach() {
super.onDetach();
MyCursor.close();
}
}

How to add a title bar in Android while sorting?

Here is my code:
public class MainActivity extends Activity {
Spinner spin;
TextView tex;
String[] country = {"A", "Afghanistan", "Albania", "Etc"};// A to Z country names
String[] code = {"+93", "+91", "Etc"}; // A to Z country Code
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
spin = (Spinner)findViewById(R.id.spinner1);
tex = (TextView)findViewById(R.id.tex);
ArrayAdapter aa1 = new ArrayAdapter(this, android.R.layout.simple_spinner_item, country);
aa1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spin.setPrompt("Select the Country");
spin.setAdapter(aa1);
spin.setOnItemSelectedListener(new OnItemSelectedListener() {
#Override
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
tex.setText(code[arg2]);
// tex.setText(country[arg2]);
}
#Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
}
}
I want to display the country's list in alphabetic order on spinner. And before that it should display the A, B, C up to Z. But This A to Z must be unselectable mode in spinner list. How can I achieve that?
You'll have to create your custom adapter that extends the ArrayAdapter.
it will probably be very easy, something like:
// the get view on your adapter
getView(LayoutInflater, etc, etc){
convertView = super.getView(inflater, etc, etc);
if(getItem(position).equals("A") || getItem(position).equals("B") || // etc, or create some clever way to go through a ArrayList with just the letters ){
convertView. // set not clickable stuff
}
}
but I reckon the Spinner still will close the list whenever the user clicks. Maybe you must override the spinner OnItemClick to get a coherent behaviour.

Order of OnItemSelectedListener Calls After OnCreate

I have two spinners in an Activity where the second Spinner's selection set is based on what the user picked for the first Spinner. I use a private class variable in the Activity which is set in the top Spinner's OnItemSelectedListener and then referenced in the bottom Spinner's OnItemSelectedListener to obtain the correct selection set.
This almost always works, but sometimes (mainly when app was run, not exited, and then started again by a user click some long time later) I get a null pointer exception in the second Spinner's OnItemSelectedListener due to this local variable not being set. This indicates to me that after the OnCreate that the second Spinner's OnItemSelectedListener was called before the first Spinner's.
Is there any method to force a certain order in the listeners being fired or is there a better design approach to handle this second Spinner's dependency on the first Spinner?
Example code:
package com.crashtestdummylimited.navydecoder;
public class Test extends Activity {
// Variable that at times is still null
private ReferenceData referenceData;
private void setupSpinnerFromArray (int spinnerId, String stringArray[], OnItemSelectedListener listener) {
Spinner spinner = (Spinner) findViewById(spinnerId);
ArrayAdapter <CharSequence> adapter = new ArrayAdapter <CharSequence>(
this, android.R.layout.simple_spinner_item, stringArray);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(listener);
}
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_screen);
// Setup Top (main) Spinner
Spinner spinner1 = (Spinner) findViewById(R.id.mainDecodeSpinner);
ArrayAdapter<CharSequence> adapter1 = ArrayAdapter.createFromResource(
this, R.array.level0_list_array, android.R.layout.simple_spinner_item);
adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner1.setAdapter(adapter1);
spinner1.setOnItemSelectedListener(new MainDecoderItemSelectedListener());
// Setup Bottom (dependent) Spinner
setupSpinnerFromArray(R.id.secondaryDecodeSpinner, R.array.level1_list_array, new SecondaryDecoderItemSelectedListener());
}
public class MainDecoderItemSelectedListener implements OnItemSelectedListener {
public void onItemSelected(AdapterView<?> parent,
View view, int pos, long id) {
String selectedString = parent.getItemAtPosition(pos).toString();
if (selectedString.equals("AAA")){
// Problem variable is set
referenceData = new RatingCodes();
setupSpinnerFromArray(R.id.secondaryDecodeSpinner, referenceData.getKeys(), new SecondaryDecoderItemSelectedListener());
}
else if (selectedString.equals("BBB")){
// Problem variable is set
referenceData = new IMSCodes();
setupSpinnerFromArray(R.id.secondaryDecodeSpinner, referenceData.getKeys(), new SecondaryDecoderItemSelectedListener());
}
// TODO: Improve what occurs if no match which should not occur
}
public void onNothingSelected(AdapterView<?> parent) {
// Do nothing.
}
}
public class SecondaryDecoderItemSelectedListener implements OnItemSelectedListener {
public void onItemSelected(AdapterView<?> parent,
View view, int pos, long id) {
String key = parent.getItemAtPosition(pos).toString();
// **** referenceData being null at this point has caused crashed ****
String value = referenceData.getValue(key);
// ... Update text on activity screen ...
}
public void onNothingSelected(AdapterView<?> parent) {
// Do nothing.
}
}
}
public void onItemSelected(AdapterView<?> parent,View view, int pos, long id)
{
if(pos == 0)
{ //when it loads on onCreate() then pos is always 0
//donothing
}
else
{ //If user manually select item
//do what you need to do on manual user selection
}
}

How to get spinner string value on android?

I have created a spinner and the items of spinner comes from database. However, When I use
public class MyOnItemSelectedListener implements OnItemSelectedListener {
public void onItemSelected(AdapterView<?> parent,
View view, int pos, long id) {
typeOFBCard = contactSpinner.getSelectedItem().toString();
}
public void onNothingSelected(AdapterView parent) {
// Do nothing.
}
}
When I call this listener and try to pick the chosen string of the spinner i get a reference of the sglite something like:
android.database.sqlite.SQLiteCursor#40535568
This is the return value of typeOfBCard.
However, on the spinner I can see normal string like "Work".
Here is how I initialized the spinner :
contactSpinner = (Spinner) findViewById(R.id.contactSpinner);
mobileText =(EditText) findViewById(R.id.mobileText);
mDbHelper = new DbAdapter(this);
mDbHelper.open();
cursor = mDbHelper.fetchAllBusinessCards();
startManagingCursor(cursor);
context =this;
contactSpinner.setOnItemSelectedListener(new MyOnItemSelectedListener());
How ever on the spinner I can see normal string like "Work"
That is because you configured an Adapter on the Spinner, and the Adapter is pulling data out of the Cursor to display.
How to get spinner string value on android?
There is no "spinner string value". Spinners don't have strings. They have views. Those views might be instances of TextView, or they might be instances of ImageView, or they might be instances of a LinearLayout holding onto a TextView and an ImageView, or...
If you want to get data out of the Cursor, call getString() on the Cursor.
Every row in a spinner is a view but it's also a value/object from your source.
Try
public class MyOnItemSelectedListener implements OnItemSelectedListener {
public void onItemSelected(AdapterView<?> parent,
View view, int pos, long id) {
// Parent == where the click happened.
typeOFBCard = parent.getSelectedItem().toString();
}
public void onNothingSelected(AdapterView parent) {
// Do nothing.
}
}

void is an invalid type for the variable onListItemClick?

I've been trying to set up a simple onClickListener on an android activity which extends ListActivity.
Within this classes on create method, I create a spinner object which when a user selects an item, an arrayAdapter list item is created, depending on what the user selected (populated from a cursor request). This is generated within another method within the same class.
ArrayAdapter<String> playerAdapter = new ArrayAdapter<String>(this,
R.layout.match_update_rows, R.id.player_name, playerItems);
setListAdapter(playerAdapter);
I'm trying to add a click listener on this new list. I have added:
#Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
Intent i = new Intent(this, PlayerFixtureScore.class);
i.putExtra("RowId", id);
startActivity(i);
}
However, I'm getting an error on the protected void onListItemClick line.
Multiple markers at this line
- Syntax error on token ")", ; expected
- Syntax error on token ",", ; expected
- Duplicate local variable position
- Syntax error on token ",", ; expected
- Duplicate local variable id
- Duplicate local variable l
- Syntax error on token "(", ; expected
- Duplicate local variable v
- Syntax error on token ",", ; expected
- void is an invalid type for the variable
onListItemClick
Also, if I select the onListItemClick line, Eclipse says 'void is an invalid type for the variable onListItemClick'?
All works if I remove the click listener code, just cannot work out how to add the listener on the arrayAdapter item so I can tell which item the user has clicked on -- any help appreciated!
As requested by MyD - here is the complete class listing:
Thanks for your prompt responses. In reply to MByD here is the complete code listing for this class. Any suggestions appreciated!
public class MatchUpdate extends ListActivity {
/** Called when the activity is first created. */
private int cursorCounter = 0;
private int spinnerSelected;
/** Set up the db for inital use */
DataBaseHelper myDbHelper = new DataBaseHelper(this);
Match match;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.match_update);
try {
myDbHelper.createDataBase();
} catch (IOException ioe) {
throw new Error("Unable to create database");
}
try {
myDbHelper.openDataBase();
} catch (SQLException sqle) {
throw sqle;
}
// create a spinner for fixture selection
Spinner fixtureSpin = (Spinner) findViewById(R.id.fixtures);
// Get all fixtures for Spinner...
Cursor cur = myDbHelper.getFixtures();
// create match object for cursor results
match = new Match(cur.getCount());
// Populate match object with Cursor results
for (cur.moveToFirst(); !cur.isAfterLast(); cur.moveToNext()) {
match.setFixtureId(cursorCounter, cur.getInt(0));
match.setHomeId(cursorCounter, cur.getInt(1));
match.setHomeTeam(cursorCounter, cur.getString(2));
match.setAwayId(cursorCounter, cur.getInt(3));
match.setAwayTeam(cursorCounter, cur.getString(4));
match.setDate(cursorCounter, cur.getString(5));
cursorCounter++;
}
// Set up adapters for fixture spinner
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, match.getFixtureList());
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// Set up fixture spinner
fixtureSpin.setAdapter(adapter);
// Set fixture spinner listener
fixtureSpin.setOnItemSelectedListener(new MyOnItemSelectedListener());
}
public class MyOnItemSelectedListener implements OnItemSelectedListener {
public void onItemSelected(AdapterView<?> parent, View view, int pos,
long id) {
spinnerSelected = parent.getSelectedItemPosition();
updatePlayers(match);
}
public void onNothingSelected(AdapterView<?> parent) {
// Do nothing.
}
}
public void updatePlayers(Match thisMatch) {
// Get players for selected fixture based on Spinner selection
Cursor playerCur = myDbHelper.getFixturePlayers(
thisMatch.getHomeId(spinnerSelected),
thisMatch.getAwayId(spinnerSelected));
// set up simple ArrayAdapter to hold player names
String[] playerItems;
playerItems = new String[playerCur.getCount()];
int cnt = 0;
// pull player data from cursor, into a simple array
for (playerCur.moveToFirst(); !playerCur.isAfterLast(); playerCur
.moveToNext()) {
playerItems[cnt] = playerCur.getString(0);
cnt++;
}
ArrayAdapter<String> playerAdapter = new ArrayAdapter<String>(this,
R.layout.match_update_rows, R.id.player_name, playerItems);
setListAdapter(playerAdapter);
#Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
Intent i = new Intent(this, PlayerFixtureScore.class);
i.putExtra("RowId", id);
startActivity(i);
}
}
}
Method declarations need to be made in the context of a class definition. When trying to declare a method inside another method, errors similar to this are reported.
I just got this error from trying to put an OnClick handler within a MenuItem method, so check you are outside of a MenuItem.

Categories

Resources