Search Results

Search found 32 results on 2 pages for 'expandablelistview'.

Page 1/2 | 1 2  | Next Page >

  • Android - Launch Intent within ExpandableListView

    - by Ryan
    Hello, I'm trying to figure out if it is possible to launch an intent within an ExpandableListView. Basically one of the "Groups" is Phone Number and it's child is the number. I want the user to be able to click it and have it automatically call that number. Is this possible? How? Here is my code to populate the ExpandableListView using a Map called "data". ExpandableListView myList = (ExpandableListView) findViewById(R.id.myList); //ExpandableListAdapter adapter = new MyExpandableListAdapter(data); List<Map<String, String>> groupData = new ArrayList<Map<String, String>>(); List<List<Map<String, String>>> childData = new ArrayList<List<Map<String, String>>>(); Iterator it = data.entrySet().iterator(); while (it.hasNext()) { //Get the key name and value for it Map.Entry pair = (Map.Entry)it.next(); String keyName = (String) pair.getKey(); String value = pair.getValue().toString(); //Add the parents -- aka main categories Map<String, String> curGroupMap = new HashMap<String, String>(); groupData.add(curGroupMap); curGroupMap.put("NAME", keyName); //Add the child data List<Map<String, String>> children = new ArrayList<Map<String, String>>(); Map<String, String> curChildMap = new HashMap<String, String>(); children.add(curChildMap); curChildMap.put("NAME", value); childData.add(children); } // Set up our adapter mAdapter = new SimpleExpandableListAdapter( mContext, groupData, R.layout.exp_list_parent, new String[] { "NAME", "IS_EVEN" }, new int[] { R.id.rowText1, R.id.rowText2 }, childData, R.layout.exp_list_child, new String[] { "NAME", "IS_EVEN" }, new int[] { R.id.rowText3, R.id.rowText4} ); myList.setAdapter(mAdapter);

    Read the article

  • Hide divider without hiding childDivider on ExpandableListView

    - by thomaus
    I can't find a way to hide dividers on an ExpandableListView without hiding the child dividers too. Here is my code. <ExpandableListView android:id="@+id/activities_list" android:background="@android:color/transparent" android:fadingEdge="none" android:groupIndicator="@android:color/transparent" android:divider="@android:color/transparent" android:childDivider="@drawable/list_divider" android:layout_width="fill_parent" android:layout_height="wrap_content" /> With this code, I get no dividers on groups but no child dividers neither. If I set android:divider to "@drawable/list_divider" I get both group and child dividers. Thanks in advance!

    Read the article

  • Android ExpandableListView From Database

    - by SterAllures
    I want to create a two level ExpandableListView from a local database. The group level I want to get the names from the database Category table category_id | name ------------------- 1 | NameOfCategory the children level I want to get the names from the List table list_id | name | foreign_category_id -------------------------------- 1 | Listname | 1 I've got a method in DatabaseDAO to get all the values from the table public List<Category> getAllCategories() { database = dbHelper.getReadableDatabase(); List<Category> categories = new ArrayList<Category>(); Cursor cursor = database.query(SQLiteHelper.TABLE_CATEGORY, null, null, null, null, null, null); cursor.moveToFirst(); while(!cursor.isAfterLast()) { Category category = cursorToCategory(cursor); categories.add(category); cursor.moveToNext(); } cursor.close(); return categories; } Now adding the names to the group level is easy I do it the following way: ArrayList<String> groups; for(Category c : databaseDao.getAllCategories()) { groups.add(c.getName()); } Now I want to add the children to the ExpandableListView in the following array ArrayList<ArrayList<ArrayList<String>>> children;. How do I get the children under the correct group name? I think it has to do somenthing with groups.indexOf() but in the list table I only have a foreign category_id and not the actual name.

    Read the article

  • ExpandableListView.setAdapter() throws IllegalStateException

    - by vijay
    I am getting the following exception: java.lang.IllegalStateException: get field slot from row 0 col -1 failed when I call setAdapter() on my ExpandableListView. Can someone please help me fix this problem? (I have already wasted 2 days :( ) Cursor mCursor = tasksListCursor(); Log.i("ChronicleTaskList", "rowcount: "+mCursor.getCount()); startManagingCursor(mCursor); boolean flag = mCursor.moveToFirst(); while (flag) { // This loop executes fine. long id = mCursor.getLong(mCursor.getColumnIndexOrThrow(ChronicleDb.KEY_ID)); String name = mCursor.getString(mCursor.getColumnIndexOrThrow(ChronicleDb.KEY_NAME)); long from = mCursor.getLong(mCursor.getColumnIndexOrThrow(ChronicleDb.KEY_FROM)); long to = mCursor.getLong(mCursor.getColumnIndexOrThrow(ChronicleDb.KEY_TO)); Log.i("ChronicleTaskList", id + ", "+ name+ ", "+ from+ ", "+to); flag = mCursor.moveToNext(); } String[] grpFromCols = { ChronicleDb.KEY_NAME}; int[] grpToVals = { R.id.cGroupRowTextName }; String[] fromCols = { TasksDbAdapter.KEY_TODODATE, TasksDbAdapter.KEY_NAME }; int[] toVals = { R.id.textViewDate2, R.id.taskRowTextTask }; ChronicleTreeListAdapterSimple adapter = new ChronicleTreeListAdapterSimple(this, mCursor, R.layout.c_group_row, grpFromCols, grpToVals, R.layout.task_row2, fromCols, toVals, true); expandableListView.setAdapter(adapter); The last line throws the exception. And the Adapter looks like this: public class ChronicleTreeListAdapterSimple extends SimpleCursorTreeAdapter { protected static String TAG = "ChronicleTreeListAdapter"; public ChronicleTreeListAdapterSimple( ChronicleTaskList context, Cursor cursor, int groupLayout, String[] groupFrom, int[] groupTo, int childLayout, String[] childFrom, int[] childTo, boolean showGroupName) { super(context, cursor, groupLayout, groupFrom, groupTo, childLayout, childFrom, childTo); taskList = context; }

    Read the article

  • Android - ExpandableListView change background for child items

    - by DroidIn.net
    I'm using ExpandableListView in my app and one of the complains I get from the users is that when the list item is expanded it's hard to visually distinguish where the child item ends and next group item begins. So I would like to change background of the child list item to the different shade. Brutal attempts that I've made so far were based on directly changing background color and text of the elements inside the child view item but that leads to loss of hovers and highlights. So my question is - what is a good strategy to achieve the above? I tried styles and selectors but what really bums me - if I change background for child item then I need to add selectors for all combinations of focus/enabled etc. when all I'm trying to do it to overwrite a single thing. Is there a way to inherit parent style and set background only for non- focused, enabled child item with other styles retained?

    Read the article

  • Androids ExpandableListView - where to put the button listener for buttons that are children

    - by CommonKnowledge
    I have been playing around a lot with the ExpandableListView and I cannot figure out where to add the button listeners for the button that will be the children in the view. I did manage to get a button listener working that uses getChildView() below, but it seems to be the same listener for all the buttons. The best case scenario is that I would be able to implement the button listeners in the class that instantiates the ExpandableListAdapter class, and not have to put the listeners in the actual ExpandableListAdapter class. At this point I don't even know if that is possible I have been experimenting with this tutorial/code: HERE getChildView() @Override public View getChildView(int set_new, int child_position, boolean view, View view1, ViewGroup view_group1) { ChildHolder childHolder; if (view1 == null) { view1 = LayoutInflater.from(info_context).inflate(R.layout.list_group_item_lv, null); childHolder = new ChildHolder(); childHolder.section_btn = (Button)view1.findViewById(R.id.item_title); view1.setTag(childHolder); childHolder.section_btn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Toast.makeText(info_context, "button pushed", Toast.LENGTH_SHORT).show(); } }); }else { childHolder = (ChildHolder) view1.getTag(); } childHolder.section_btn.setText(children_collection.get(set_new).GroupItemCollection.get(child_position).section); Typeface tf = Typeface.createFromAsset(info_context.getAssets(), "fonts/AGENCYR.TTF"); childHolder.section_btn.setTypeface(tf); return view1; } Any help would be much appreciated. Thank you and I will be standing by.

    Read the article

  • ExpandableListView child items don't get focus when touched...

    - by Justin
    Ok, so I wrote an ExpandableListView and subclassed BaseExpandableListAdapter... Everything works fine except I cannot get the child views to take focus when clicked. If I use the trackball everything works fine. But if I try to click on a child I get no feedback whatsoever. I have tried setting android:focusable, android:focusableInTouchMode, and android:clickable (and I have also tried setting this via code) but I can't get anything to work. Any ideas? Here is my Adapter code: public class ExpandableAppAdapter extends BaseExpandableListAdapter { private PackageManager m_pkgMgr; private Context m_context; private List<ApplicationInfo> m_groups; private List<List<ComponentName>> m_children; public ExpandableAppAdapter(Context context, List<ApplicationInfo> groups, List<List<ComponentName>> children) { m_context = context; m_pkgMgr = m_context.getPackageManager(); m_groups = groups; m_children = children; } @Override public Object getChild(int groupPos, int childPos) { return m_children.get(groupPos).get(childPos); } @Override public long getChildId(int groupPos, int childPos) { return childPos; } @Override public int getChildrenCount(int groupPos) { return m_children.get(groupPos).size(); } @Override public View getChildView(int groupPos, int childPos, boolean isLastChild, View convertView, ViewGroup parent) { if (convertView == null) { LayoutInflater inflater = LayoutInflater.from(m_context); convertView = inflater.inflate(R.layout.expandable_app_child_row, null); } ComponentName child = (ComponentName)getChild(groupPos, childPos); TextView txtView = (TextView)convertView.findViewById(R.id.item_app_pkg_name_id); if (txtView != null) txtView.setText(child.getPackageName()); txtView = (TextView)convertView.findViewById(R.id.item_app_class_name_id); if (txtView != null) txtView.setText(child.getClassName()); convertView.setFocusableInTouchMode(true); return convertView; } @Override public Object getGroup(int groupPos) { return m_groups.get(groupPos); } @Override public int getGroupCount() { return m_groups.size(); } @Override public long getGroupId(int groupPos) { return groupPos; } @Override public View getGroupView(int groupPos, boolean isExpanded, View convertView, ViewGroup parent) { if (convertView == null) { LayoutInflater inflater = LayoutInflater.from(m_context); convertView = inflater.inflate(R.layout.expandable_app_group_row, null); } ApplicationInfo group = (ApplicationInfo)getGroup(groupPos); ImageView imgView = (ImageView)convertView.findViewById(R.id.item_selection_icon_id); if (imgView != null) { Drawable img = m_pkgMgr.getApplicationIcon(group); imgView.setImageDrawable(img); imgView.setMaxWidth(20); imgView.setMaxHeight(20); } TextView txtView = (TextView)convertView.findViewById(R.id.item_app_name_id); if (txtView != null) txtView.setText(m_pkgMgr.getApplicationLabel(group)); return convertView; } @Override public boolean hasStableIds() { return false; } @Override public boolean isChildSelectable(int groupPos, int childPos) { return true; } } Thanks in advance!

    Read the article

  • In an ExpandableListView, how can I show one additional line at the end of the child results?

    - by fiXedd
    I have created a custom ExpandableListAdapter and everything works properly. What I'd like to be able to do is in each of the groups add a different type of child to the end. I have tried adding 1 to the getChildrenCount() number and then testing isLastChild in the getChildView() method, but that doesn't seem to work. If a group has three children what I have working looks like this: Group NormalChild NormalChild NormalChild But I'd really like something like this: Group NormalChild NormalChild NormalChild AlternateChild The idea being that the AlternateChild could be a link to more info about the group. Any Ideas? EDIT: ListView has addFooterView() which will allow you to add a footer to a whole ListView... wonder how to add them to the ExpandableListView's children, or if it's even possible

    Read the article

  • Is choiceMode compatible with ExpandableListView?

    - by kostmo
    Is it possible to make a multiple choice list with android:choiceMode="multipleChoice" or setChoiceMode(ListView.CHOICE_MODE_MULTIPLE) on an ExpandableListView? I am able to do this with CheckBoxes on a plain ListView, but it doesn't seem to be working with ExpandableListView. In the latter, clicking the list item (either parent or child) does not affect the checkbox as it does in the former. I have noticed that it is possible to click exactly on the checkbox to make it toggle, but this is a very small target.

    Read the article

  • Cursor backed ExpandableListView data update

    - by Aleksander O
    Hi I'm implementing CRUD functionality using ExpandableListView. Wen I delete a parent data on screen refreshes automatically but it doesn't when I delete a child. I've solved this with: int categoryId = ExpandableListView.getPackedPositionGroup(info.packedPosition); getExpandableListView().collapseGroup(categoryId); getExpandableListView().expandGroup(categoryId); Is there any better way to this? Thanks Aleksander

    Read the article

  • ExpandableListView context menu

    - by Aleksander O
    I'm trying to add a context menu to my ExpandableListView. I've implemented onCreateContextMenu() and onContextItemSelected() but if I hold my finger on a menu item context menu doesn't appear. What's my mistake? Thanks, Aleksander

    Read the article

  • Problem with Refreshing data in ExpandableListView

    - by -providerivan.longin1
    Hi! My problem is when I want to refresh data in ExpandableListView while being in that current activity. I create adapter and when I want to add new data to list I call again constructor of that adapter(it is my private variable) with all new data....and then I call onContentChanged() method to redraw my list. But what happens is that I cant expand my list any more...like it is blocked or something and logcat isn't saying anything... This is the code that i call after setting new data in arraylists and maps: mAdapter = new MyExpandableListAdapter( this, groupData, R.layout.contact_list_parent, new String[] { NAME ,NUM_PHOTOS},//NUM_PHOTOS new int[] { R.id.rowText1, R.id.rowText2, R.id.photoAlbumImg }, childData, R.layout.contact_list_child, new String[] { NAME,NUM_PHOTOS}, //NUM_PHOTOS new int[] { R.id.rowText1, R.id.rowText2, R.id.photoAlbumImg } ); this.onContentChanged(); If anyone knows answer to this question please help me:) Thanks.

    Read the article

  • Dynamic ExpandableListView

    - by JLB
    Can anyone tell me how I can Dynamically add groups & children to an ExpandableListView. The purpose is to create a type of task list that I can add new items/groups to. I can populate the view with pre-filled arrays but of course can't add to them to populate the list further. The other method i tried was using the SimpleExpandableListAdapter. Using this i am able to add groups from a List but when it comes to adding children i can only add 1 item per group. public List<Map<String, String>> groupData = new ArrayList<Map<String, String>>(); public List<List<Map<String, String>>> childData = new ArrayList<List<Map<String, String>>>(); public void addGroup(String group) { Map curGroupMap = new HashMap(); groupData.add(curGroupMap); curGroupMap.put(NAME, group); //Add an empty child or else the app will crash when group is expanded. List<Map<String, String>> children = new ArrayList<Map<String, String>>(); Map<String, String> curChildMap = new HashMap<String, String>(); children.add(curChildMap); curChildMap.put(NAME, "EMPTY"); childData.add(children); updateAdapter(); } public void addChild(String child) { List children = new ArrayList(); Map curChildMap = new HashMap(); children.add(curChildMap); curChildMap.put(NAME, child); curChildMap.put(IS_EVEN, "This child is even"); childData.add(activeGroup, children); updateAdapter(); }

    Read the article

  • Expand Expandable Listview in android on button Click

    - by user3146145
    I am implementing expandable list view with its custom adapter. The group element needs to have 2 buttons, first as a parent group element and a button below it. My problem is, I want to expand the list view on click of the button below instead of the group element. Also, The group element onClick needs to call another activity. I can disable the expanding of the expandablelistview by `mainExpListView.setOnGroupClickListener(new OnGroupClickListener() { @Override public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { return false; }` So my questions: Is there any way to disable the group element and get it to perform other functions (Like navigate to another activity?) How to set an onclick method on them bottom image to expand? Thank you.

    Read the article

  • Android Expandable List View Update

    - by Gaurav Arora
    I am implementing a chatting application, where I have made a service to listen all the presence changed. On the change of the presence I want to update the data and I am unable to update the data that is showing in the expandable list view. Please suggest me a means to do the same. public class UserMenuActivity extends ExpandableListActivity { private XMPPConnection connection; String name,availability,subscriptionStatus; TextView tv_Status; /** Variable Define here */ private String[] data = { "View my profile", "New Multiperson Chat", "New Broad Cast Message", "New Contact Category", "New Group", "Invite to CCM", "Search", "Expand All", "Settings", "Help", "Close" }; private String[] data_Contact = { "Rename Category","Move Contact to Category", "View my profile", "New Multiperson Chat", "New Broad Cast Message", "New Contact Category", "New Group", "Invite to CCM", "Search", "Expand All", "Settings", "Help", "Close" }; private String[] data_child_contact = { "Open chat", "Delete Contact","View my profile", "New Multiperson Chat", "New Broad Cast Message", "New Contact Category", "New Group", "Invite to CCM", "Search", "Expand All", "Settings", "Help", "Close" }; private String[] menuItem = { "Chats", "Contacts", "CGM Groups", "Pending","Request" }; private List<String> menuItemList = Arrays.asList(menuItem); private int commonGroupPosition = 0; private String etAlertVal; private DatabaseHelper dbHelper; private int categoryID, listPos; /** New Code here.. */ private ArrayList<String> groupNames; private ArrayList<ArrayList<ChildItems>> childs; private UserMenuAdapter adapter; private Object object; private String[] data2 = { "PIN Michelle", "IP Call" }; private ListView mlist2; private ImageButton mimBtnMenu; private LinearLayout mllpopmenu; private View popupView; private PopupWindow popupWindow; private AlertDialog.Builder alert; private EditText input; private TextView mtvUserName, mtvUserTagLine; private ExpandableListView mExpandableListView; public static List<CategoryDataClass> categoryList; private boolean menuType = false; private String childValContact=""; public static Context context; @Override public void onBackPressed() { if (mllpopmenu.getVisibility() == View.VISIBLE) { mllpopmenu.setVisibility(View.INVISIBLE); } else { if (CCMStaticVariable.CommonConnection.isConnected()) { CCMStaticVariable.CommonConnection.disconnect(); } super.onBackPressed(); } } @SuppressWarnings("unchecked") @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_MENU) { if (mllpopmenu.getVisibility() == View.VISIBLE) { mllpopmenu.setVisibility(View.INVISIBLE); } else { if (commonGroupPosition >= 4 && menuType == true) { if(childValContact == ""){ mllpopmenu.setVisibility(View.VISIBLE); mlist2.setAdapter(new ArrayAdapter(UserMenuActivity.this, R.layout.listviewtext, R.id.tvMenuText, data_Contact)); }else{ mllpopmenu.setVisibility(View.VISIBLE); mlist2.setAdapter(new ArrayAdapter(UserMenuActivity.this, R.layout.listviewtext, R.id.tvMenuText, data_child_contact)); } } else if (commonGroupPosition == 0) { mllpopmenu.setVisibility(View.VISIBLE); mlist2.setAdapter(new ArrayAdapter(UserMenuActivity.this, R.layout.listviewtext, R.id.tvMenuText, data)); } } return true; } return super.onKeyDown(keyCode, event); } @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.usermenulayout); dbHelper = new DatabaseHelper(UserMenuActivity.this); //this.context = context.getApplicationContext(); XMPPConn.getContactList(); connection = CCMStaticVariable.CommonConnection; Presence userPresence = new Presence(Presence.Type.available); userPresence.setPriority(24); userPresence.setMode(Presence.Mode.away); connection.sendPacket(userPresence); } @Override protected void onResume() { super.onResume(); Presence userPresence = new Presence(Presence.Type.available); userPresence.setPriority(24); userPresence.setMode(Presence.Mode.away); connection.sendPacket(userPresence); XMPPConn.getContactList(); setExpandableListView(); } public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { if (groupPosition == 1 && childPosition == 0) { startActivity(new Intent(UserMenuActivity.this, InvitetoCCMActivity.class)); } else if (groupPosition == 1 && childPosition != 0) { Intent intent = new Intent(UserMenuActivity.this, UserChatActivity.class); intent.putExtra("userNameVal", XMPPConn.mfriendList.get(childPosition - 1).friendName); startActivity(intent); } else if (groupPosition == 2 && childPosition == 0) { startActivity(new Intent(UserMenuActivity.this, CreateGroupActivity.class)); } else if (groupPosition == 2 && childPosition != 0) { String GROUP_NAME = childs.get(groupPosition).get(childPosition) .getName().toString(); int end = GROUP_NAME.indexOf("("); CCMStaticVariable.groupName = GROUP_NAME.substring(0, end).trim(); startActivity(new Intent(UserMenuActivity.this, GroupsActivity.class)); } else if (groupPosition >= 4) { childValContact = childs.get(groupPosition).get(childPosition).getName().trim(); showToast("user==>"+childValContact, 0); } return false; } private void setExpandableListView() { /***###############GROUP ARRAY ############################*/ final ArrayList<String> groupNames = new ArrayList<String>(); groupNames.add("Chats (2)"); groupNames.add("Contacts (" + XMPPConn.mfriendList.size() + ")"); groupNames.add("CGM Groups (" + XMPPConn.mGroupList.size() + ")"); groupNames.add("Pending (1)"); XMPPConn.getGroup(); categoryList = dbHelper.getAllCategory(); /**Group From Sever*/ if (XMPPConn.mGroupList.size() > 0) { for (int g = 0; g < XMPPConn.mGroupList.size(); g++) { XMPPConn.getGroupContact(XMPPConn.mGroupList.get(g).groupName); groupNames.add(XMPPConn.mGroupList.get(g).groupName + "(" + XMPPConn.mGroupContactList.size()+ ")"); } } if(categoryList.size() > 0){ for (int cat = 0; cat < categoryList.size(); cat++) { groupNames.add(categoryList.get(cat).getCategoryName()+ "(0)"); } } this.groupNames = groupNames; /*** ###########CHILD ARRAY * #################*/ ArrayList<ArrayList<ChildItems>> childs = new ArrayList<ArrayList<ChildItems>>(); ArrayList<ChildItems> child = new ArrayList<ChildItems>(); child.add(new ChildItems("Alisha", "Hi",0)); child.add(new ChildItems("Michelle", "Good Morning",0)); childs.add(child); child = new ArrayList<ChildItems>(); child.add(new ChildItems("", "",0)); if (XMPPConn.mfriendList.size() > 0) { for (int n = 0; n < XMPPConn.mfriendList.size(); n++) { child.add(new ChildItems(XMPPConn.mfriendList.get(n).friendNickName, XMPPConn.mfriendList.get(n).friendStatus, XMPPConn.mfriendList.get(n).friendState)); } } childs.add(child); /************** CGM Group Child here *********************/ child = new ArrayList<ChildItems>(); child.add(new ChildItems("", "",0)); if (XMPPConn.mGroupList.size() > 0) { for (int grop = 0; grop < XMPPConn.mGroupList.size(); grop++) { child.add(new ChildItems( XMPPConn.mGroupList.get(grop).groupName + " (" + XMPPConn.mGroupList.get(grop).groupUserCount + ")", "",0)); } } childs.add(child); child = new ArrayList<ChildItems>(); child.add(new ChildItems("Shuchi", "Pending (Waiting for Authorization)",0)); childs.add(child); /************************ Group Contact List *************************/ if (XMPPConn.mGroupList.size() > 0) { for (int g = 0; g < XMPPConn.mGroupList.size(); g++) { /** Contact List */ XMPPConn.getGroupContact(XMPPConn.mGroupList.get(g).groupName); child = new ArrayList<ChildItems>(); for (int con = 0; con < XMPPConn.mGroupContactList.size(); con++) { child.add(new ChildItems( XMPPConn.mGroupContactList.get(con).friendName, XMPPConn.mGroupContactList.get(con).friendStatus,0)); } childs.add(child); } } if(categoryList.size() > 0){ for (int cat = 0; cat < categoryList.size(); cat++) { child = new ArrayList<ChildItems>(); child.add(new ChildItems("-none-", "",0)); childs.add(child); } } this.childs = childs; /** Set Adapter here */ adapter = new UserMenuAdapter(this, groupNames, childs); setListAdapter(adapter); object = this; mlist2 = (ListView) findViewById(R.id.list2); mimBtnMenu = (ImageButton) findViewById(R.id.imBtnMenu); mllpopmenu = (LinearLayout) findViewById(R.id.llpopmenu); mtvUserName = (TextView) findViewById(R.id.tvUserName); mtvUserTagLine = (TextView) findViewById(R.id.tvUserTagLine); //Set User name.. System.out.println("CCMStaticVariable.loginUserName===" + CCMStaticVariable.loginUserName); if (!CCMStaticVariable.loginUserName.equalsIgnoreCase("")) { mtvUserName.setText("" + CCMStaticVariable.loginUserName); } /** Expandable List set here.. */ mExpandableListView = (ExpandableListView) this .findViewById(android.R.id.list); mExpandableListView.setOnGroupClickListener(new OnGroupClickListener() { @Override public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { XMPPConn.getContactList(); if (parent.isGroupExpanded(groupPosition)) { commonGroupPosition = 0; }else{ commonGroupPosition = groupPosition; } String GROUP_NAME = groupNames.get(groupPosition); int end = groupNames.get(groupPosition).indexOf("("); String GROUP_NAME_VALUE = GROUP_NAME.substring(0, end).trim(); if (menuItemList.contains(GROUP_NAME_VALUE)) { menuType = false; CCMStaticVariable.groupCatName = GROUP_NAME_VALUE; } else { menuType = true; CCMStaticVariable.groupCatName = GROUP_NAME_VALUE; } long findCatId = dbHelper.getCategoryID(GROUP_NAME_VALUE); if (findCatId != 0) { categoryID = (int) findCatId; } childValContact=""; showToast("Clicked on==" + GROUP_NAME_VALUE, 0); return false; } }); /** Click on item */ mlist2.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int pos,long arg3) { if (commonGroupPosition >= 4) { if(childValContact == ""){ if (pos == 0) { showAlertEdit(CCMStaticVariable.groupCatName); } /** Move contact to catgory */ if (pos == 1) { startActivity(new Intent(UserMenuActivity.this,AddContactCategoryActivity.class)); } }else{ if(pos == 0){ Intent intent = new Intent(UserMenuActivity.this,UserChatActivity.class); intent.putExtra("userNameVal",childValContact); startActivity(intent); } if(pos == 1){ XMPPConn.removeEntry(childValContact); showToast("Contact deleted sucessfully", 0); Intent intent = new Intent(UserMenuActivity.this,UserMenuActivity.class); } } } else { /** MyProfile */ if (pos == 0) { startActivity(new Intent(UserMenuActivity.this, MyProfileActivity.class)); } /** New multiperson chat start */ if (pos == 1) { startActivity(new Intent(UserMenuActivity.this, NewMultipersonChatActivity.class)); } /** New Broadcast message */ if (pos == 2) { startActivity(new Intent(UserMenuActivity.this, NewBroadcastMessageActivity.class)); } /** Click on add category */ if (pos == 3) { showAlertAdd(); } if (pos == 4) { startActivity(new Intent(UserMenuActivity.this, CreateGroupActivity.class)); } if (pos == 5) { startActivity(new Intent(UserMenuActivity.this, InvitetoCCMActivity.class)); } if (pos == 6) { startActivity(new Intent(UserMenuActivity.this, SearchActivity.class)); } if (pos == 7) { onGroupExpand(2); for (int i = 0; i < groupNames.size(); i++) { mExpandableListView.expandGroup(i); } } /** Click on settings */ if (pos == 8) { startActivity(new Intent(UserMenuActivity.this, SettingsActivity.class)); } if (pos == 10) { System.exit(0); } if (pos == 14) { if (mllpopmenu.getVisibility() == View.VISIBLE) { mllpopmenu.setVisibility(View.INVISIBLE); if (popupWindow.isShowing()) { popupWindow.dismiss(); } } else { mllpopmenu.setVisibility(View.VISIBLE); mlist2.setAdapter(new ArrayAdapter( UserMenuActivity.this, R.layout.listviewtext, R.id.tvMenuText, data)); } } } } }); } /** Toast message display here.. */ private void showToast(String msg, int time) { Toast.makeText(this, msg, time).show(); } public String showSubscriptionStatus(String friend){ return friend; } } Service.class public class UpdaterService extends Service { private XMPPConnection connection; String Friend; String user = ""; @Override public IBinder onBind(Intent arg0) { // TODO Auto-generated method stub return null; } @Override public void onCreate() { // Toast.makeText(this, "My Service Created", Toast.LENGTH_LONG).show(); super.onCreate(); } @Override public void onDestroy() { // TODO Auto-generated method stub super.onDestroy(); } @Override public void onStart(Intent intent, int startId) { // TODO Auto-generated method stub showToast("My Service Started", 0); connection = getConnection(); if (connection.isConnected()) { final Roster roster = connection.getRoster(); RosterListener r1 = new RosterListener() { @Override public void presenceChanged(Presence presence) { // TODO Auto-generated method stub XMPPConn.getContactList(); } @Override public void entriesUpdated(Collection<String> arg0) { // TODO Auto-generated method stub //notification("entriesUpdated"); } @Override public void entriesDeleted(Collection<String> arg0) { // TODO Auto-generated method stub //notification("entriesDeleted"); } @Override public void entriesAdded(Collection<String> arg0) { // TODO Auto-generated method stub Iterator<String> it = arg0.iterator(); if (it.hasNext()) { user = it.next(); } RosterEntry entry = roster.getEntry(user); if(entry.getType().toString().equalsIgnoreCase("to")){ int index_of_Alpha = Friend.indexOf("@"); String subID = Friend.substring(0, index_of_Alpha); notification("Hi "+subID+" wants to add you"); } } }; if (roster != null) { roster.setSubscriptionMode(Roster.SubscriptionMode.manual); System.out.println("subscription going on"); roster.addRosterListener(r1); } } else { showToast("Connection lost-", 0); } } protected void showToast(String msg, int time) { Toast.makeText(this, msg, time).show(); } private XMPPConnection getConnection() { return CCMStaticVariable.CommonConnection; } /** Notification manager */ private void notification(CharSequence message) { String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns); int icon = R.drawable.ic_launcher; CharSequence tickerText = message; long when = System.currentTimeMillis(); Notification notification = new Notification(icon, tickerText, when); Context context = getApplicationContext(); CharSequence contentTitle = "CCM"; CharSequence contentText = message; Intent notificationIntent = new Intent(this, ManageNotification.class); notificationIntent.putExtra("Subscriber_ID",user ); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent); notification.flags |= Notification.FLAG_AUTO_CANCEL; final int HELLO_ID = 1; mNotificationManager.notify(HELLO_ID, notification); } } Here is my adapter class public class UserMenuAdapter extends BaseExpandableListAdapter { private ArrayList<String> groups; private ArrayList<ArrayList<ChildItems>> childs; private Context context; public LayoutInflater inflater; ImageView img_availabiliy; private static final int[] EMPTY_STATE_SET = {}; private static final int[] GROUP_EXPANDED_STATE_SET = {android.R.attr.state_expanded}; private static final int[][] GROUP_STATE_SETS = { EMPTY_STATE_SET, // 0 GROUP_EXPANDED_STATE_SET // 1 }; public UserMenuAdapter(Context context, ArrayList<String> groups, ArrayList<ArrayList<ChildItems>> childs) { this.context = context; this.groups = groups; this.childs = childs; inflater = LayoutInflater.from(context); } @Override public Object getChild(int groupPosition, int childPosition) { return childs.get(groupPosition).get(childPosition); } @Override public long getChildId(int groupPosition, int childPosition) { return (long) (groupPosition * 1024 + childPosition); } @Override public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { View v = null; if (convertView != null) v = convertView; else v = inflater.inflate(R.layout.child_layout, parent, false); ChildItems ci = (ChildItems) getChild(groupPosition, childPosition); TextView tv = (TextView) v.findViewById(R.id.tvChild); tv.setText(ci.getName()); TextView tv2 = (TextView) v.findViewById(R.id.tvChild2); tv2.setText(ci.getDailyStatus()); img_availabiliy = (ImageView)v.findViewById(R.id.img_childlayout_AVAILABILITY); ImageView friendPics = (ImageView)v.findViewById(R.id.ivFriendPics); if(ci.getStatusState() == 1){ img_availabiliy.setImageResource(R.drawable.online); } else if(ci.getStatusState()==0){ img_availabiliy.setImageResource(R.drawable.offline); } else if (ci.getStatusState()==2) { img_availabiliy.setImageResource(R.drawable.away); } else if(ci.getStatusState()==3){ img_availabiliy.setImageResource(R.drawable.busy); } else{ img_availabiliy.setImageDrawable(null); } if((groupPosition == 1 && childPosition == 0)){ friendPics.setImageResource(R.drawable.inviteto_ccm); img_availabiliy.setVisibility(View.INVISIBLE); } else if(groupPosition == 2 && childPosition == 0){ friendPics.setImageResource(R.drawable.new_ccmgroup); img_availabiliy.setVisibility(View.VISIBLE); }else{ if(ci.getPicture()!= null){ Bitmap bitmap = BitmapFactory.decodeByteArray(ci.getPicture(), 0, ci.getPicture().length); bitmap = Bitmap.createScaledBitmap(bitmap, 50, 50, true); friendPics.setImageBitmap(bitmap); }else{ friendPics.setImageResource(R.drawable.avatar); } img_availabiliy.setVisibility(View.VISIBLE); } return v; } @Override public int getChildrenCount(int groupPosition) { return childs.get(groupPosition).size(); } @Override public Object getGroup(int groupPosition) { return groups.get(groupPosition); } @Override public int getGroupCount() { return groups.size(); } @Override public long getGroupId(int groupPosition) { return (long) (groupPosition * 1024); } @Override public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { View v = null; if (convertView != null) v = convertView; else v = inflater.inflate(R.layout.group_layout, parent, false); String gt = (String) getGroup(groupPosition); TextView tv2 = (TextView) v.findViewById(R.id.tvGroup); if (gt != null) tv2.setText(gt); /**Set Image on group layout, Max/min*/ View ind = v.findViewById( R.id.explist_indicator); View groupInd = v.findViewById( R.id.llgroup); if( ind != null ) { ImageView indicator = (ImageView)ind; if( getChildrenCount( groupPosition ) == 0 ) { indicator.setVisibility( View.INVISIBLE ); } else { indicator.setVisibility( View.VISIBLE ); int stateSetIndex = ( isExpanded ? 1 : 0) ; Drawable drawable = indicator.getDrawable(); drawable.setState(GROUP_STATE_SETS[stateSetIndex]); } } if( groupInd != null ) { RelativeLayout indicator2 = (RelativeLayout)groupInd; if( getChildrenCount( groupPosition ) == 0 ) { indicator2.setVisibility( View.INVISIBLE ); } else { indicator2.setVisibility( View.VISIBLE ); int stateSetIndex = ( isExpanded ? 1 : 0) ; Drawable drawable2 = indicator2.getBackground(); drawable2.setState(GROUP_STATE_SETS[stateSetIndex]); } } return v; } @Override public boolean hasStableIds() { return true; } @Override public boolean isChildSelectable(int groupPosition, int childPosition) { return true; } public void onGroupCollapsed(int groupPosition) { } public void onGroupExpanded(int groupPosition) { } } I just want to update my list in ON PRESENCE CHANGED method in the Service class.. Please suggest me a means to do the same.

    Read the article

  • Blackberry - View similar to Blackberry Messenger, MSN or Gtalk

    - by Alexander
    A View with expand and contract list where you show, for instance, Chats, Contacts, Groups. You click on of them and expands to a list of Chats and each element of the list is a Rectangular box with User defined image, name, status (offline, online, busy) as an image and status message. How can i program a view as described? thanks in advance

    Read the article

  • ImageView scale type not working in list activity

    - by Justin
    I have used ImageView's before and understand the different scale types that can be set... However I am having an incredibly difficult time trying to get an ImageView to scale properly in the row of a ListActivity or an ExpandableListActivity. I have tried setting the android:scaleType property to every single value but the image never scales down. I have set the min and max sizes as well and they don't seem to have any effect. I have done both of these things in both the XMl and in code to no avail... Does anyone have any ideas or perhaps a workaround? Thanks in advance!

    Read the article

  • Adding a imageview to child elements in a expandable list query

    - by Thomas Millin
    I am looking to find out how to assign an image to a imageview in each child of an expandable list. If anyone has any information or links to find out how to do this I would be most appreciative. expListAdapter = new SimpleExpandableListAdapter( main.this, createGroupList(), R.layout.parentnode, new String[] { "day", "number" }, new int[] { R.id.TextView01, R.id.TextView02 }, createChildList(), R.layout.child_row, new String[] { "image", "childName", "date"}, new int[] { R.id.ImageView01, R.id.childname, R.id.date } ); setListAdapter( expListAdapter ); is what my adapter looks like at the moment, I have very little experience in customising adapters so I do not know where to start. Any help would be great :D

    Read the article

  • What adapter to use for ExpandableListView with non-TextView views?

    - by David
    I have an ExpandableListView in which I'd like to have controls other than TextView. Apparently, SimpleExandableListViewAdapter assumes all the controls are TextViews. A cast exception is generated if they are not. What is the recommended solution? Options I can think of include: - Use some other included adapter. But I can't tell if they all have the same assumption. - Create my own adapter. Is there a doc which describes the contract, ie the sequence of method calls an adapter will encounter? I expected the existing adapters to require the views to conform to some interface to allow any conforming view to be used, rather than hardcode to textview and limit where they can be used.

    Read the article

  • Android: How can i access email addresses in android

    - by Maxood
    I have the following code through which i am able to retrieve phone numbers. Somehow , i am not able to retrieve email addresses by using android.provider.Contacts.People API. Any ideas? import android.app.AlertDialog; import android.app.ExpandableListActivity; import android.content.ContentUris; import android.content.Context; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.provider.Contacts.People; import android.view.View; import android.widget.ExpandableListAdapter; import android.widget.SimpleCursorTreeAdapter; import android.widget.TextView; import android.widget.ExpandableListView.OnChildClickListener; public class ShowContacts extends ExpandableListActivity implements OnChildClickListener { private int mGroupIdColumnIndex; private String mPhoneNumberProjection[] = new String[] { People.Phones._ID, People.NUMBER // CHANGE HERE }; private ExpandableListAdapter mAdapter; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Query for people Cursor groupCursor = managedQuery(People.CONTENT_URI, new String[] {People._ID, People.NAME}, null, null, null); // Cache the ID column index mGroupIdColumnIndex = groupCursor.getColumnIndexOrThrow(People._ID); // Set up our adapter mAdapter = new MyExpandableListAdapter(groupCursor, this, android.R.layout.simple_expandable_list_item_1, android.R.layout.simple_expandable_list_item_1, new String[] {People.NAME}, // Name for group layouts new int[] {android.R.id.text1}, new String[] {People.NUMBER}, // AND CHANGE HERE new int[] {android.R.id.text1}); setListAdapter(mAdapter); } public class MyExpandableListAdapter extends SimpleCursorTreeAdapter { public MyExpandableListAdapter(Cursor cursor, Context context, int groupLayout, int childLayout, String[] groupFrom, int[] groupTo, String[] childrenFrom, int[] childrenTo) { super(context, cursor, groupLayout, groupFrom, groupTo, childLayout, childrenFrom, childrenTo); } @Override protected Cursor getChildrenCursor(Cursor groupCursor) { // Given the group, we return a cursor for all the children within that group // Return a cursor that points to this contact's phone numbers Uri.Builder builder = People.CONTENT_URI.buildUpon(); ContentUris.appendId(builder, groupCursor.getLong(mGroupIdColumnIndex)); builder.appendEncodedPath(People.Phones.CONTENT_DIRECTORY); Uri phoneNumbersUri = builder.build(); return managedQuery(phoneNumbersUri, mPhoneNumberProjection, null, null, null); } } @Override public boolean onChildClick(android.widget.ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { AlertDialog dialog = new AlertDialog.Builder(ShowContacts.this) .setMessage(((TextView) v).getText().toString()) .setPositiveButton("OK", null).create(); dialog.show(); return true; } }

    Read the article

1 2  | Next Page >