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);
}
});
}
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");
}
}
}
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;
}
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();
}
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;
}
Aggregations