List of usage examples for android.widget ExpandableListView PACKED_POSITION_TYPE_CHILD
int PACKED_POSITION_TYPE_CHILD
To view the source code for android.widget ExpandableListView PACKED_POSITION_TYPE_CHILD.
Click Source Link
From source file:com.arcusapp.soundbox.fragment.ArtistsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_artists, container, false); ExpandableListView myExpandableList = (ExpandableListView) rootView .findViewById(R.id.expandableListArtists); myExpandableList.setGroupIndicator(null); myExpandableList.setOnItemLongClickListener(new OnItemLongClickListener() { @Override/* w ww .j a va 2 s . c o m*/ public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { if (ExpandableListView.getPackedPositionType(id) == ExpandableListView.PACKED_POSITION_TYPE_GROUP) { int groupPosition = ExpandableListView.getPackedPositionGroup(id); myAdapter.onArtistLongClick(groupPosition); return true; } else if (ExpandableListView .getPackedPositionType(id) == ExpandableListView.PACKED_POSITION_TYPE_CHILD) { int groupPosition = ExpandableListView.getPackedPositionGroup(id); int childPosition = ExpandableListView.getPackedPositionChild(id); myAdapter.onAlbumLongClick(groupPosition, childPosition); return true; } return false; } }); myExpandableList.setOnChildClickListener(new OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { myAdapter.onAlbumClick(groupPosition, childPosition); return false; } }); myExpandableList.setAdapter(myAdapter); return rootView; }
From source file:org.tigase.mobile.roster.RosterFragment.java
private static long extractId(ContextMenuInfo menuInfo) { if (menuInfo instanceof ExpandableListContextMenuInfo) { int type = ExpandableListView .getPackedPositionType(((ExpandableListContextMenuInfo) menuInfo).packedPosition); if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) { return ((ExpandableListContextMenuInfo) menuInfo).id; } else//w w w . jav a 2 s . c o m return -1; } else if (menuInfo instanceof AdapterContextMenuInfo) { return ((AdapterContextMenuInfo) menuInfo).id; } else { return -1; } }
From source file:com.kaproduction.malibilgiler.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); coordinatorLayoutMainActivity = (CoordinatorLayout) findViewById(R.id.coordinatorLayoutMainActivity); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);//from ww w . ja v a2s. c om getSupportActionBar().setIcon(R.mipmap.ic_launcher1); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); //Deneme Yourum Yazildi...... NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); expandableListView = (ExpandableListView) findViewById(R.id.exp_list); mCategory = ExpandableListViewData.getInfo(); mlist = new ArrayList<String>(mCategory.keySet()); adapter = new ExpandableListViewAdapter(this, mCategory, mlist); expandableListView.setAdapter(adapter); expandableListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView expandableListView, View view, int parent, int child, long l) { String heading = (String) adapter.getGroup(parent); String message = (String) adapter.getChild(parent, child); alertDialog(heading, message); // Toast.makeText(getApplicationContext(), result, Toast.LENGTH_LONG).show(); return true; } }); expandableListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> adapterView, View view, int position, long id) { if (ExpandableListView.getPackedPositionType(id) == ExpandableListView.PACKED_POSITION_TYPE_CHILD) { int groupPosition = ExpandableListView.getPackedPositionGroup(id); int childPosition = ExpandableListView.getPackedPositionChild(id); String text = (String) adapter.getChild(groupPosition, childPosition); String heading = (String) adapter.getGroup(groupPosition); alertDialogForClipboard(heading, text); } return true; } }); }
From source file:org.peercast.core.PeerCastFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo; int type = ExpandableListView.getPackedPositionType(info.packedPosition); int gPos = ExpandableListView.getPackedPositionGroup(info.packedPosition); int cPos = ExpandableListView.getPackedPositionChild(info.packedPosition); if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) { // ??//from ww w . j a v a 2s . c o m getActivity().getMenuInflater().inflate(R.menu.channel_context_menu, menu); Channel ch = mListAdapter.getGroup(gPos); menu.setHeaderTitle(ch.getInfo().getName()); MenuItem mKeep = menu.findItem(R.id.menu_ch_keep); mKeep.setChecked(ch.isStayConnected()); } else if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) { // getActivity().getMenuInflater().inflate(R.menu.servent_context_menu, menu); Servent svt = mListAdapter.getChild(gPos, cPos); menu.setHeaderTitle(svt.getHost()); } }
From source file:org.openmidaas.app.activities.AttributeListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mFragmentActiviy = (FragmentActivity) super.getActivity(); mRelativeLayout = (RelativeLayout) inflater.inflate(R.layout.attribute_list_view, container, false); mAttributeListView = (ExpandableListView) mRelativeLayout.findViewById(R.id.listViewAttributes); mAttributeListView.setClickable(true); mAttributeListView.setItemsCanFocus(true); mAttributeListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); mAdapter = new AttributeExpandableListAdapter(mFragmentActiviy); mAttributeListView.setAdapter(mAdapter); mAttributeListView.setOnChildClickListener(new OnChildClickListener() { @Override/*ww w .ja va 2s . com*/ public boolean onChildClick(ExpandableListView arg0, View arg1, int groupPosition, int childPosition, long id) { OnListElementTouch element = (OnListElementTouch) mAdapter.getChild(groupPosition, childPosition); if (element != null) { element.onTouch(mFragmentActiviy); } return false; } }); mAttributeListView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { if (ExpandableListView.getPackedPositionType(id) == ExpandableListView.PACKED_POSITION_TYPE_CHILD) { OnListElementLongTouch element = (OnListElementLongTouch) mAdapter.getChild( ExpandableListView.getPackedPositionGroup(id), ExpandableListView.getPackedPositionChild(id)); if (element != null) { element.onLongTouch(mFragmentActiviy); } return true; } return false; } }); return mRelativeLayout; }
From source file:can.yrt.onebusaway.RouteInfoListFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo; if (ExpandableListView .getPackedPositionType(info.packedPosition) != ExpandableListView.PACKED_POSITION_TYPE_CHILD) { return;/*from w w w . j a v a 2s. co m*/ } final TextView text = (TextView) info.targetView.findViewById(R.id.name); menu.setHeaderTitle(text.getText()); menu.add(0, CONTEXT_MENU_DEFAULT, 0, R.string.route_info_context_get_stop_info); menu.add(0, CONTEXT_MENU_SHOWONMAP, 0, R.string.route_info_context_showonmap); }
From source file:com.login.home.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo; String title = ((TextView) info.targetView).getText().toString(); menu.setHeaderTitle(title);/*w ww . ja va 2 s.com*/ int type = ExpandableListView.getPackedPositionType(info.packedPosition); if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) { super.onCreateContextMenu(menu, v, menuInfo); int groupPos = ExpandableListView.getPackedPositionGroup(info.packedPosition); if (groupPos == 1 || groupPos == 0) { menu.add(1, 0, 0, "ACCEPT"); menu.add(1, 1, 0, "DECLINE"); menu.add(1, 2, 0, "SHOW INFO"); } else if (groupPos == 2) { menu.add(1, 0, 0, "SHOW INFO"); menu.add(1, 1, 0, "SHOW ON A MAP"); menu.add(1, 2, 0, "WILL NOT ATTEND"); } } }
From source file:com.money.manager.ex.common.CategoryListFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo; int type = ExpandableListView.getPackedPositionType(info.packedPosition); int group = ExpandableListView.getPackedPositionGroup(info.packedPosition); int child = ExpandableListView.getPackedPositionChild(info.packedPosition); if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) { menu.setHeaderTitle(mCategories.get(group).getName()); } else if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) { QueryCategorySubCategory subCategory = mSubCategories.get(mCategories.get(group)).get(child); menu.setHeaderTitle(//from w w w . jav a 2 s .com subCategory.getCategName().toString() + ": " + subCategory.getSubcategoryName().toString()); } // context menu from resource menu.add(Menu.NONE, ContextMenuIds.EDIT.getId(), Menu.NONE, getString(R.string.edit)); menu.add(Menu.NONE, ContextMenuIds.DELETE.getId(), Menu.NONE, getString(R.string.delete)); menu.add(Menu.NONE, ContextMenuIds.VIEW_TRANSACTIONS.getId(), Menu.NONE, getString(R.string.view_transactions)); }
From source file:com.login.home.java
@Override public boolean onContextItemSelected(MenuItem item) { ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo(); int type = ExpandableListView.getPackedPositionType(info.packedPosition); if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) { int groupPos = ExpandableListView.getPackedPositionGroup(info.packedPosition); int childPos = ExpandableListView.getPackedPositionChild(info.packedPosition); @SuppressWarnings("unchecked") HashMap<String, String> o = (HashMap<String, String>) mAdapter.getChild(groupPos, childPos); SharedPreferences settings = getSharedPreferences("pref_meetmethere", 0); ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>(); String log = settings.getString("login", "error"); String pass = settings.getString("password", "error"); postParameters.add(new BasicNameValuePair("login", log)); postParameters.add(new BasicNameValuePair("password", pass)); postParameters.add(new BasicNameValuePair("id", o.get("id"))); if (groupPos == 1 || groupPos == 0) { switch (item.getItemId()) { case 0: postParameters.add(new BasicNameValuePair("confirmed", "1")); break; case 1: postParameters.add(new BasicNameValuePair("confirmed", "2")); break; case 2: if (groupPos == 0) { Intent intent = new Intent(home.this, event_info.class); intent.putExtra("longitude", o.get("longitude")); intent.putExtra("latitude", o.get("latitude")); intent.putExtra("willAttend", o.get("willAttend")); intent.putExtra("address", o.get("address")); intent.putExtra("id", o.get("id")); intent.putExtra("title", o.get("title")); intent.putExtra("startdate", o.get("startdate")); intent.putExtra("enddate", o.get("enddate")); intent.putExtra("address", o.get("address")); intent.putExtra("description", o.get("description")); startActivity(intent); } else if (groupPos == 1) { String friend = o.get("login"); Intent intent = new Intent(home.this, profile.class); intent.putExtra("friend", friend); intent.putExtra("yourrequest", "true"); intent.putExtra("id", o.get("id")); intent.putExtra("confirmed", "0"); startActivity(intent); }/*from w w w .j a v a2 s .c o m*/ break; } String response = null; try { if (groupPos == 1) response = CustomHttpClient.executeHttpPost( "http://antoines.goldzoneweb.info/accept_contact.php", postParameters); else response = CustomHttpClient.executeHttpPost( "http://antoines.goldzoneweb.info/accept_event.php", postParameters); String res = response.toString(); res = res.replaceAll("\\s+", ""); if (res.equals("OK")) { Intent myIntent = new Intent(home.this, home.class); startActivityForResult(myIntent, 0); } } catch (Exception e) { System.out.println("Error occured"); } } else if (groupPos == 2) { switch (item.getItemId()) { case 0: Intent intent = new Intent(home.this, event_info.class); intent.putExtra("longitude", o.get("longitude")); intent.putExtra("latitude", o.get("latitude")); intent.putExtra("willAttend", o.get("willAttend")); intent.putExtra("address", o.get("address")); intent.putExtra("id", o.get("id")); intent.putExtra("title", o.get("title")); intent.putExtra("startdate", o.get("startdate")); intent.putExtra("enddate", o.get("enddate")); intent.putExtra("address", o.get("address")); intent.putExtra("description", o.get("description")); startActivity(intent); break; case 1: Intent intent2 = new Intent(home.this, mapevent.class); intent2.putExtra("longitude", o.get("longitude")); intent2.putExtra("latitude", o.get("latitude")); intent2.putExtra("willAttend", o.get("willAttend")); intent2.putExtra("address", o.get("address")); intent2.putExtra("id", o.get("id")); intent2.putExtra("title", o.get("title")); intent2.putExtra("startdate", o.get("startdate")); intent2.putExtra("enddate", o.get("enddate")); intent2.putExtra("address", o.get("address")); intent2.putExtra("description", o.get("description")); startActivity(intent2); break; case 2: postParameters.add(new BasicNameValuePair("confirmed", "2")); String response = null; try { response = CustomHttpClient.executeHttpPost( "http://antoines.goldzoneweb.info/accept_event.php", postParameters); String res = response.toString(); res = res.replaceAll("\\s+", ""); if (res.equals("OK")) { Intent myIntent = new Intent(home.this, home.class); startActivityForResult(myIntent, 0); } } catch (Exception e) { System.out.println("Error occured"); } break; } } } else if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) { return true; } return false; }
From source file:edu.chalmers.dat255.audiobookplayer.view.BookshelfFragment.java
@SuppressWarnings("rawtypes") @Override//from w w w .j ava2 s .c o m public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { // check that the menuInfo is of the correct type // this method is allowed to have quite a high cyclomatic complexity as // it would otherwise cause code duplication if (menuInfo instanceof ExpandableListContextMenuInfo && adapter != null) { ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo; // get the provided book position int bookIndex = ExpandableListView.getPackedPositionGroup(info.packedPosition); // trackIndex will be -1 if group is clicked int trackIndex = ExpandableListView.getPackedPositionChild(info.packedPosition); // get the type of the context menu int type = ExpandableListView.getPackedPositionType(info.packedPosition); // create an empty array to prevent trying to loop over an // uninitialized variable IContextMenuItem[] menuItems = new IContextMenuItem[0]; String title = ""; // fill the context menu with the correct items if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) { // get all menu items from the child context menu menuItems = ChildContextMenuItem.values(); // set the context menu's title to that of the value of the // child title = adapter.getChild(bookIndex, trackIndex); } else if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) { // get all menu items from the group context menu menuItems = GroupContextMenuItem.values(); // set the context menu's title to that of the value of the book title = adapter.getGroup(bookIndex); } // set the title menu.setHeaderTitle(title); // populate the context menu with items in the order they were // declared in the enum declaration. for (IContextMenuItem item : menuItems) { // as this only loops when menuItems is of either of type // GroupContextMenuItem[] or ChildContextMenuItem[], Enum can be // used as a raw type menu.add(Menu.NONE, ((Enum) item).ordinal(), ((Enum) item).ordinal(), item.getText()); } } }