Java Code Examples for android.widget.AdapterView#getContext()

The following examples show how to use android.widget.AdapterView#getContext() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EditMicroBlogAccountSelectorItemClickListener.java    From YiBo with Apache License 2.0 6 votes vote down vote up
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
		long id) {
	BaseAdapter adapter = AdapterUtil.getAdapter(parent.getAdapter());
	if (!(adapter instanceof AccountSelectorListAdapter)) {
		return;
	}
	
	LocalAccount account = (LocalAccount)adapter.getItem(position);
       if (selectorWindow.isSelected(account)) {
       	selectorWindow.removeSelectedAccount(account);
       } else {
       	selectorWindow.addSelectedAccount(account);
       }
       
       EditMicroBlogActivity context = (EditMicroBlogActivity)parent.getContext();
       context.setListUpdateAccount(selectorWindow.getSelectedAccounts());
       context.updateSelectorText();
}
 
Example 2
Source File: GOneToManyConnectedComboView.java    From geopaparazzi with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onItemSelected(AdapterView<?> parent, View callingView, int pos, long arg3) {
    if (parent == mainComboSpinner) {
        String mainComboItem = mainComboSpinner.getSelectedItem().toString();

        List<NamedList<String>> namedLists = new ArrayList<>();
        if (mainComboItem.length() != 0) {
            namedLists = dataMap.get(mainComboItem);
        }
        for (int i = 0; i < namedLists.size(); i++) {
            NamedList<String> namedList = namedLists.get(i);
            TextView subTextView = orderedSubTextviewsList.get(i);
            subTextView.setText(namedList.name);

            Spinner subSpinner = orderedSubCombosList.get(i);
            ArrayAdapter<String> combo2ListAdapter = new ArrayAdapter<String>(parent.getContext(), android.R.layout.simple_spinner_dropdown_item, namedList.items);
            combo2ListAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            subSpinner.setAdapter(combo2ListAdapter);
        }
    }
}
 
Example 3
Source File: MessageClickListener.java    From Atomic with GNU General Public License v3.0 5 votes vote down vote up
private void doThing(AdapterView<?> group, int position) {
  android.util.Log.d("MessageClickListener", "clicking on item => "+position);
  MessageListAdapter adapter = (MessageListAdapter)group.getAdapter();
  Message m = adapter.getItem(position);
  Intent intent = new Intent(group.getContext(), MessageActivity.class);
  // this is going to be a parcelable.
  // Woo parcelables.
  intent.putExtra(Extra.MESSAGE, m);

  group.getContext().startActivity(intent);
}
 
Example 4
Source File: GTwoConnectedComboView.java    From geopaparazzi with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onItemSelected(AdapterView<?> parent, View callingView, int pos, long arg3) {
    if (parent == combo1Spinner) {
        String combo1Item = combo1Spinner.getSelectedItem().toString();
        List<String> valuesList = new ArrayList<>();
        if (combo1Item.length() != 0) {
            valuesList = dataMap.get(combo1Item);
        }
        ArrayAdapter<String> valuesListAdapter = new ArrayAdapter<>(parent.getContext(), android.R.layout.simple_spinner_dropdown_item, valuesList);
        valuesListAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        combo2Spinner.setAdapter(valuesListAdapter);
    }
}
 
Example 5
Source File: AppGridItemClickListener.java    From YiBo with Apache License 2.0 4 votes vote down vote up
@Override
	public void onItemClick(AdapterView<?> parent, View view, int position,
			long id) {
		Adapter adapter = parent.getAdapter();
        long appImageId = adapter.getItemId(position);

        Activity context = (Activity)parent.getContext();
        Intent intent = new Intent();
        if (appImageId == R.drawable.icon_app_search) {
        	intent.setClass(context, SearchActivity.class);
        } else if (appImageId == R.drawable.icon_app_public_timeline) {
        	intent.setClass(context, PublicTimelineActivity.class);
        } else if (appImageId == R.drawable.icon_app_hot_retweet) {
        	intent.setClass(context, HotStatusesActivity.class);
        	intent.putExtra("STATUS_CATALOG", StatusCatalog.Hot_Retweet.getCatalogNo());
        } else if (appImageId == R.drawable.icon_app_hot_comment) {
        	intent.setClass(context, HotStatusesActivity.class); 
        	intent.putExtra("STATUS_CATALOG", StatusCatalog.Hot_Comment.getCatalogNo());
        } else if (appImageId == R.drawable.icon_app_hot_topic) {
        	//intent.setClass(context, HotTopicsActivity.class);
        	intent.setClass(context, StatusSubscribeActivity.class);
        	intent.putExtra("STATUS_CATALOG", StatusCatalog.Picture_Mobile.getCatalogNo());
        	intent.putExtra("TITLE_ID", R.string.label_app_hot_topic);
        } else if (appImageId == R.drawable.icon_app_daily) {
        	intent.setClass(context, StatusSubscribeActivity.class);
        	intent.putExtra("STATUS_CATALOG", StatusCatalog.News.getCatalogNo());
        	intent.putExtra("TITLE_ID", R.string.label_app_daily);
        } else if (appImageId == R.drawable.icon_app_image) {
        	intent.setClass(context, StatusSubscribeActivity.class);
        	intent.putExtra("STATUS_CATALOG", StatusCatalog.Picture.getCatalogNo());
        	intent.putExtra("TITLE_ID", R.string.label_app_image);
        } else if (appImageId == R.drawable.icon_app_jokes) {
        	intent.setClass(context, StatusSubscribeActivity.class);
        	intent.putExtra("STATUS_CATALOG", StatusCatalog.Joke.getCatalogNo());
        	intent.putExtra("TITLE_ID", R.string.label_app_jokes);
        } else if (appImageId == R.drawable.icon_app_exchange) {
        	ConfigSystemDao configDao = new ConfigSystemDao(context);
		    String username = configDao.getString(Constants.PASSPORT_USERNAME);
//		    if (StringUtil.isEmpty(username)) {
//      	          AppConnect.getInstance(context).showOffers(context);
//      	    } else {
//      		  AppConnect.getInstance(context).showOffers(context, username);
//            }
      	    return;
        } else {
        	Toast.makeText(context, "抱歉,此功能正在开发中..", Toast.LENGTH_LONG).show();
        	return;
        }

        context.startActivity(intent);
	}