Search in sources :

Example 61 with ExpandableListView

use of android.widget.ExpandableListView in project android_frameworks_base by crdroidandroid.

the class ShortcutPickHelper method processShortcut.

private void processShortcut(final Intent intent, int requestCodeApplication, int requestCodeShortcut) {
    // Handle case where user selected "Applications"
    String applicationName = mParent.getString(R.string.profile_applist_title);
    String application2name = mParent.getString(R.string.picker_activities);
    String shortcutName = intent.getStringExtra(Intent.EXTRA_SHORTCUT_NAME);
    if (applicationName != null && applicationName.equals(shortcutName)) {
        Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
        mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
        Intent pickIntent = new Intent(Intent.ACTION_PICK_ACTIVITY);
        pickIntent.putExtra(Intent.EXTRA_INTENT, mainIntent);
        startFragmentOrActivity(pickIntent, requestCodeApplication);
    } else if (application2name != null && application2name.equals(shortcutName)) {
        final List<PackageInfo> pInfos = mPackageManager.getInstalledPackages(PackageManager.GET_ACTIVITIES);
        ExpandableListView appListView = new ExpandableListView(mParent);
        AppExpandableAdapter appAdapter = new AppExpandableAdapter(pInfos, mParent);
        appListView.setAdapter(appAdapter);
        appListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {

            @Override
            public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
                Intent shortIntent = new Intent(Intent.ACTION_MAIN);
                String pkgName = ((GroupInfo) parent.getExpandableListAdapter().getGroup(groupPosition)).info.packageName;
                String actName = ((GroupInfo) parent.getExpandableListAdapter().getGroup(groupPosition)).info.activities[childPosition].name;
                shortIntent.setClassName(pkgName, actName);
                completeSetCustomApp(shortIntent);
                mAlertDialog.dismiss();
                return true;
            }
        });
        Builder builder = new Builder(mParent);
        builder.setView(appListView);
        mAlertDialog = builder.create();
        mAlertDialog.setTitle(mParent.getString(R.string.select_custom_activity_title));
        mAlertDialog.show();
        mAlertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {

            @Override
            public void onCancel(DialogInterface dialog) {
                mListener.shortcutPicked(null, null, false);
            }
        });
    } else {
        startFragmentOrActivity(intent, requestCodeShortcut);
    }
}
Also used : DialogInterface(android.content.DialogInterface) Builder(android.app.AlertDialog.Builder) Intent(android.content.Intent) ArrayList(java.util.ArrayList) List(java.util.List) TextView(android.widget.TextView) View(android.view.View) ExpandableListView(android.widget.ExpandableListView) ExpandableListView(android.widget.ExpandableListView)

Example 62 with ExpandableListView

use of android.widget.ExpandableListView in project android-diplicity by zond.

the class MainActivity method setupNavigation.

private void setupNavigation() {
    navigationRootGroups = new ArrayList<Map<String, String>>() {

        {
            add(new HashMap<String, String>() {

                {
                    put("ROOT_NAME", getResources().getString(R.string.games));
                }
            });
            add(new HashMap<String, String>() {

                {
                    put("ROOT_NAME", getResources().getString(R.string.users));
                }
            });
        }
    };
    navigationChildGroups = new ArrayList<List<Map<String, String>>>();
    List<Map<String, String>> childGroupForFirstGroupRow = new ArrayList<Map<String, String>>() {

        {
            add(new HashMap<String, String>() {

                {
                    put("CHILD_NAME", getResources().getString(R.string.my_started));
                }
            });
            add(new HashMap<String, String>() {

                {
                    put("CHILD_NAME", getResources().getString(R.string.my_staging));
                }
            });
            add(new HashMap<String, String>() {

                {
                    put("CHILD_NAME", getResources().getString(R.string.my_finished));
                }
            });
            add(new HashMap<String, String>() {

                {
                    put("CHILD_NAME", getResources().getString(R.string.open));
                }
            });
            add(new HashMap<String, String>() {

                {
                    put("CHILD_NAME", getResources().getString(R.string.started));
                }
            });
            add(new HashMap<String, String>() {

                {
                    put("CHILD_NAME", getResources().getString(R.string.finished));
                }
            });
        }
    };
    navigationChildGroups.add(childGroupForFirstGroupRow);
    List<Map<String, String>> childGroupForSecondGroupRow = new ArrayList<Map<String, String>>() {

        {
            add(new HashMap<String, String>() {

                {
                    put("CHILD_NAME", getResources().getString(R.string.top_rated));
                }
            });
            add(new HashMap<String, String>() {

                {
                    put("CHILD_NAME", getResources().getString(R.string.top_reliable));
                }
            });
            add(new HashMap<String, String>() {

                {
                    put("CHILD_NAME", getResources().getString(R.string.top_quick));
                }
            });
            add(new HashMap<String, String>() {

                {
                    put("CHILD_NAME", getResources().getString(R.string.top_hated));
                }
            });
            add(new HashMap<String, String>() {

                {
                    put("CHILD_NAME", getResources().getString(R.string.top_hater));
                }
            });
        }
    };
    navigationChildGroups.add(childGroupForSecondGroupRow);
    SimpleExpandableListAdapter navigationListAdapter = new SimpleExpandableListAdapter(this, navigationRootGroups, android.R.layout.simple_expandable_list_item_1, new String[] { "ROOT_NAME" }, new int[] { android.R.id.text1 }, navigationChildGroups, android.R.layout.simple_expandable_list_item_1, new String[] { "CHILD_NAME" }, new int[] { android.R.id.text1 });
    ExpandableListView navigationList = (ExpandableListView) findViewById(R.id.nav_list);
    navigationList.setAdapter(navigationListAdapter);
    connectNavigationList(navigationList);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) ArrayList(java.util.ArrayList) SimpleExpandableListAdapter(android.widget.SimpleExpandableListAdapter) Map(java.util.Map) HashMap(java.util.HashMap) ExpandableListView(android.widget.ExpandableListView)

Example 63 with ExpandableListView

use of android.widget.ExpandableListView in project devbricks by dailystudio.

the class AbsExpandableListAdapterFragment method bindAdapterView.

@SuppressWarnings("unchecked")
protected void bindAdapterView() {
    final View fragmentView = getView();
    if (fragmentView == null) {
        return;
    }
    ExpandableListView oldAdapterView = mAdapterView;
    if (oldAdapterView != null) {
        oldAdapterView.clearDisappearingChildren();
        oldAdapterView.clearAnimation();
        oldAdapterView.setAdapter((BaseExpandableListAdapter) null);
        oldAdapterView.setOnChildClickListener(null);
        oldAdapterView.setOnGroupClickListener(null);
        oldAdapterView.setVisibility(View.GONE);
        oldAdapterView.setEmptyView(null);
    }
    mAdapter = onCreateAdapter();
    mAdapterView = (ExpandableListView) fragmentView.findViewById(getAdapterViewId());
    if (mAdapterView != null) {
        mAdapterView.setAdapter(mAdapter);
        mAdapterView.setOnChildClickListener(this);
        mAdapterView.setOnGroupClickListener(this);
        mAdapterView.setVisibility(View.VISIBLE);
        mAdapterView.scheduleLayoutAnimation();
        final View emptyView = fragmentView.findViewById(getEmptyViewId());
        if (emptyView != null) {
            mAdapterView.setEmptyView(emptyView);
        }
    }
}
Also used : View(android.view.View) ExpandableListView(android.widget.ExpandableListView) ExpandableListView(android.widget.ExpandableListView)

Example 64 with ExpandableListView

use of android.widget.ExpandableListView in project Thrift-box by Sash0k.

the class ExpandableListFragment method onCreateView.

/**
 * Provide default implementation to return a simple list view.  Subclasses
 * can override to replace with their own layout.  If doing so, the
 * returned view hierarchy <em>must</em> have a ListView whose id
 * is {@link android.R.id#list android.R.id.list} and can optionally
 * have a sibling view id {@link android.R.id#empty android.R.id.empty}
 * that is to be shown when the list is empty.
 *
 * <p>If you are overriding this method with your own custom content,
 * consider including the standard layout {@link android.R.layout#list_content}
 * in your layout file, so that you continue to retain all of the standard
 * behavior of ListFragment.  In particular, this is currently the only
 * way to have the built-in indeterminant progress state be shown.
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = getActivity();
    FrameLayout root = new FrameLayout(context);
    // ------------------------------------------------------------------
    LinearLayout pframe = new LinearLayout(context);
    pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
    pframe.setOrientation(LinearLayout.VERTICAL);
    pframe.setVisibility(View.GONE);
    pframe.setGravity(Gravity.CENTER);
    ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge);
    pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    // ------------------------------------------------------------------
    FrameLayout lframe = new FrameLayout(context);
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);
    TextView tv = new TextView(getActivity());
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(Gravity.CENTER);
    lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    ExpandableListView lv = new ExpandableListView(getActivity());
    lv.setId(android.R.id.list);
    lv.setDrawSelectorOnTop(false);
    lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    // ------------------------------------------------------------------
    root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    return root;
}
Also used : Context(android.content.Context) FrameLayout(android.widget.FrameLayout) TextView(android.widget.TextView) ProgressBar(android.widget.ProgressBar) LinearLayout(android.widget.LinearLayout) ExpandableListView(android.widget.ExpandableListView)

Example 65 with ExpandableListView

use of android.widget.ExpandableListView in project Thrift-box by Sash0k.

the class ExpandableListFragment method onContentChanged.

// /**
// * Ensures the expandable list view has been created before Activity restores all
// * of the view states.
// *
// *@see Activity#onRestoreInstanceState(Bundle)
// */
// @Override
// protected void onRestoreInstanceState(Bundle state) {
// ensureList();
// super.onRestoreInstanceState(state);
// }
/**
 * Updates the screen state (current list and other views) when the
 * content changes.
 *
 * @see Activity#onContentChanged()
 */
public void onContentChanged() {
    // super.onContentChanged();
    View emptyView = getView().findViewById(android.R.id.empty);
    mExpandableList = (ExpandableListView) getView().findViewById(android.R.id.list);
    if (mExpandableList == null) {
        throw new RuntimeException("Your content must have a ExpandableListView whose id attribute is " + "'android.R.id.list'");
    }
    if (emptyView != null) {
        mExpandableList.setEmptyView(emptyView);
    }
    mExpandableList.setOnChildClickListener(this);
    mExpandableList.setOnGroupExpandListener(this);
    mExpandableList.setOnGroupCollapseListener(this);
    if (mFinishedStart) {
        setListAdapter(mAdapter);
    }
    mFinishedStart = true;
}
Also used : TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ExpandableListView(android.widget.ExpandableListView)

Aggregations

ExpandableListView (android.widget.ExpandableListView)86 View (android.view.View)59 TextView (android.widget.TextView)30 AdapterView (android.widget.AdapterView)18 Intent (android.content.Intent)16 ListView (android.widget.ListView)16 ArrayList (java.util.ArrayList)16 AbsListView (android.widget.AbsListView)14 DialogInterface (android.content.DialogInterface)11 ImageView (android.widget.ImageView)11 List (java.util.List)11 Builder (android.app.AlertDialog.Builder)9 ViewGroup (android.view.ViewGroup)9 ExpandableListAdapter (android.widget.ExpandableListAdapter)7 AbsSpinner (android.widget.AbsSpinner)6 QuickContactBadge (android.widget.QuickContactBadge)6 TabHost (android.widget.TabHost)6 AdapterBinding (com.android.ide.common.rendering.api.AdapterBinding)6 ResourceReference (com.android.ide.common.rendering.api.ResourceReference)6 SessionParams (com.android.ide.common.rendering.api.SessionParams)6