Search in sources :

Example 26 with ListView

use of android.widget.ListView in project android_frameworks_base by ParanoidAndroid.

the class ChooseAccountTypeActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (Log.isLoggable(TAG, Log.VERBOSE)) {
        Log.v(TAG, "ChooseAccountTypeActivity.onCreate(savedInstanceState=" + savedInstanceState + ")");
    }
    // Read the validAccountTypes, if present, and add them to the setOfAllowableAccountTypes
    Set<String> setOfAllowableAccountTypes = null;
    String[] validAccountTypes = getIntent().getStringArrayExtra(ChooseTypeAndAccountActivity.EXTRA_ALLOWABLE_ACCOUNT_TYPES_STRING_ARRAY);
    if (validAccountTypes != null) {
        setOfAllowableAccountTypes = new HashSet<String>(validAccountTypes.length);
        for (String type : validAccountTypes) {
            setOfAllowableAccountTypes.add(type);
        }
    }
    // create a map of account authenticators
    buildTypeToAuthDescriptionMap();
    // Create a list of authenticators that are allowable. Filter out those that
    // don't match the allowable account types, if provided.
    mAuthenticatorInfosToDisplay = new ArrayList<AuthInfo>(mTypeToAuthenticatorInfo.size());
    for (Map.Entry<String, AuthInfo> entry : mTypeToAuthenticatorInfo.entrySet()) {
        final String type = entry.getKey();
        final AuthInfo info = entry.getValue();
        if (setOfAllowableAccountTypes != null && !setOfAllowableAccountTypes.contains(type)) {
            continue;
        }
        mAuthenticatorInfosToDisplay.add(info);
    }
    if (mAuthenticatorInfosToDisplay.isEmpty()) {
        Bundle bundle = new Bundle();
        bundle.putString(AccountManager.KEY_ERROR_MESSAGE, "no allowable account types");
        setResult(Activity.RESULT_OK, new Intent().putExtras(bundle));
        finish();
        return;
    }
    if (mAuthenticatorInfosToDisplay.size() == 1) {
        setResultAndFinish(mAuthenticatorInfosToDisplay.get(0).desc.type);
        return;
    }
    setContentView(R.layout.choose_account_type);
    // Setup the list
    ListView list = (ListView) findViewById(android.R.id.list);
    // Use an existing ListAdapter that will map an array of strings to TextViews
    list.setAdapter(new AccountArrayAdapter(this, android.R.layout.simple_list_item_1, mAuthenticatorInfosToDisplay));
    list.setChoiceMode(ListView.CHOICE_MODE_NONE);
    list.setTextFilterEnabled(false);
    list.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            setResultAndFinish(mAuthenticatorInfosToDisplay.get(position).desc.type);
        }
    });
}
Also used : Bundle(android.os.Bundle) Intent(android.content.Intent) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) ListView(android.widget.ListView) AdapterView(android.widget.AdapterView) HashMap(java.util.HashMap) Map(java.util.Map)

Example 27 with ListView

use of android.widget.ListView in project android_frameworks_base by ParanoidAndroid.

the class ChooseTypeAndAccountActivity method populateUIAccountList.

/**
     * Populates the UI ListView with the given list of items and selects an item
     * based on {@code mSelectedItemIndex} member variable.
     */
private final void populateUIAccountList(String[] listItems) {
    ListView list = (ListView) findViewById(android.R.id.list);
    list.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_single_choice, listItems));
    list.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    list.setItemsCanFocus(false);
    list.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            mSelectedItemIndex = position;
            mOkButton.setEnabled(true);
        }
    });
    if (mSelectedItemIndex != SELECTED_ITEM_NONE) {
        list.setItemChecked(mSelectedItemIndex, true);
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "List item " + mSelectedItemIndex + " should be selected");
        }
    }
}
Also used : ListView(android.widget.ListView) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView)

Example 28 with ListView

use of android.widget.ListView in project android_frameworks_base by ParanoidAndroid.

the class ListActivity method onContentChanged.

/**
     * Updates the screen state (current list and other views) when the
     * content changes.
     *
     * @see Activity#onContentChanged()
     */
@Override
public void onContentChanged() {
    super.onContentChanged();
    View emptyView = findViewById(com.android.internal.R.id.empty);
    mList = (ListView) findViewById(com.android.internal.R.id.list);
    if (mList == null) {
        throw new RuntimeException("Your content must have a ListView whose id attribute is " + "'android.R.id.list'");
    }
    if (emptyView != null) {
        mList.setEmptyView(emptyView);
    }
    mList.setOnItemClickListener(mOnClickListener);
    if (mFinishedStart) {
        setListAdapter(mAdapter);
    }
    mHandler.post(mRequestFocus);
    mFinishedStart = true;
}
Also used : View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView)

Example 29 with ListView

use of android.widget.ListView in project android_frameworks_base by ParanoidAndroid.

the class PreferenceScreen method showDialog.

private void showDialog(Bundle state) {
    Context context = getContext();
    if (mListView != null) {
        mListView.setAdapter(null);
    }
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View childPrefScreen = inflater.inflate(com.android.internal.R.layout.preference_list_fragment, null);
    mListView = (ListView) childPrefScreen.findViewById(android.R.id.list);
    bind(mListView);
    // Set the title bar if title is available, else no title bar
    final CharSequence title = getTitle();
    Dialog dialog = mDialog = new Dialog(context, context.getThemeResId());
    if (TextUtils.isEmpty(title)) {
        dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    } else {
        dialog.setTitle(title);
    }
    dialog.setContentView(childPrefScreen);
    dialog.setOnDismissListener(this);
    if (state != null) {
        dialog.onRestoreInstanceState(state);
    }
    // Add the screen to the list of preferences screens opened as dialogs
    getPreferenceManager().addPreferencesScreen(dialog);
    dialog.show();
}
Also used : Context(android.content.Context) Dialog(android.app.Dialog) LayoutInflater(android.view.LayoutInflater) AbsListView(android.widget.AbsListView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView)

Example 30 with ListView

use of android.widget.ListView in project android_frameworks_base by ParanoidAndroid.

the class MediaRouteChooserDialogFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mInflater = inflater;
    final View layout = inflater.inflate(R.layout.media_route_chooser_layout, container, false);
    mVolumeIcon = (ImageView) layout.findViewById(R.id.volume_icon);
    mVolumeSlider = (SeekBar) layout.findViewById(R.id.volume_slider);
    updateVolume();
    mVolumeSlider.setOnSeekBarChangeListener(new VolumeSliderChangeListener());
    if (mExtendedSettingsListener != null) {
        final View extendedSettingsButton = layout.findViewById(R.id.extended_settings);
        extendedSettingsButton.setVisibility(View.VISIBLE);
        extendedSettingsButton.setOnClickListener(mExtendedSettingsListener);
    }
    final ListView list = (ListView) layout.findViewById(R.id.list);
    list.setItemsCanFocus(true);
    list.setAdapter(mAdapter = new RouteAdapter());
    list.setOnItemClickListener(mAdapter);
    mListView = list;
    mAdapter.scrollToSelectedItem();
    return layout;
}
Also used : ListView(android.widget.ListView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView)

Aggregations

ListView (android.widget.ListView)1104 View (android.view.View)714 AdapterView (android.widget.AdapterView)425 TextView (android.widget.TextView)371 ImageView (android.widget.ImageView)163 Intent (android.content.Intent)144 AbsListView (android.widget.AbsListView)134 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)93 ArrayAdapter (android.widget.ArrayAdapter)93 ArrayList (java.util.ArrayList)80 ViewGroup (android.view.ViewGroup)70 ListAdapter (android.widget.ListAdapter)70 OnClickListener (android.view.View.OnClickListener)65 LayoutInflater (android.view.LayoutInflater)59 Bundle (android.os.Bundle)57 Button (android.widget.Button)55 LinearLayout (android.widget.LinearLayout)47 SuppressLint (android.annotation.SuppressLint)34 DialogInterface (android.content.DialogInterface)32 ScrollView (android.widget.ScrollView)31