use of android.widget.ArrayAdapter in project qksms by moezbhatti.
the class MMSDialogFragment method setTripleLineItems.
public MMSDialogFragment setTripleLineItems(String[] titles, String[] subtitles, String[] bodies) {
int size = Math.min(titles.length, Math.min(subtitles.length, bodies.length));
TripleLineListItem[] tripleLineListItems = new TripleLineListItem[size];
for (int i = 0; i < size; i++) {
tripleLineListItems[i] = new TripleLineListItem();
tripleLineListItems[i].title = titles[i];
tripleLineListItems[i].subtitle = subtitles[i];
tripleLineListItems[i].body = bodies[i];
}
ArrayAdapter adapter = new TripleLineArrayAdapter(mContext, tripleLineListItems);
ListView listView = new ListView(mContext);
listView.setAdapter(adapter);
listView.setDivider(null);
listView.setPadding(0, Units.dpToPx(mContext, 8), 0, Units.dpToPx(mContext, 8));
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
onListResult(LIST_ITEM_CLICK_RESULT, position);
dismiss();
}
});
return setCustomView(listView);
}
use of android.widget.ArrayAdapter in project SeriesGuide by UweTrottmann.
the class TvdbAddFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_addshow_tvdb, container, false);
unbinder = ButterKnife.bind(this, v);
// language chooser (Supported languages + any as first option)
CharSequence[] languageNamesArray = getResources().getTextArray(R.array.languagesShows);
ArrayList<CharSequence> languageNamesList = new ArrayList<>(languageNamesArray.length + 1);
languageNamesList.add(getString(R.string.any_language));
Collections.addAll(languageNamesList, languageNamesArray);
ArrayAdapter<CharSequence> adapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_item, languageNamesList);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerLanguage.setAdapter(adapter);
final String[] languageCodes = getResources().getStringArray(R.array.languageCodesShows);
language = DisplaySettings.getSearchLanguage(getContext());
if (!TextUtils.isEmpty(language)) {
for (int i = 0; i < languageCodes.length; i++) {
if (languageCodes[i].equals(language)) {
spinnerLanguage.setSelection(i + 1, false);
break;
}
}
}
spinnerLanguage.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if (position == 0) {
language = "";
} else {
language = languageCodes[position - 1];
}
// save selected search language
PreferenceManager.getDefaultSharedPreferences(parent.getContext()).edit().putString(DisplaySettings.KEY_LANGUAGE_SEARCH, language).apply();
// https://fabric.io/seriesguide/android/apps/com.battlelancer.seriesguide/issues/567bff98f5d3a7f76b9e8502
if (isVisible()) {
// refresh results in newly selected language
search();
}
Timber.d("Set search language to %s", language);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
// set initial view states
setProgressVisible(true, false);
return v;
}
use of android.widget.ArrayAdapter in project XPrivacy by M66B.
the class WhitelistTask method onPostExecute.
@Override
@SuppressLint({ "DefaultLocale", "InflateParams" })
protected void onPostExecute(Object result) {
if (!mContext.isFinishing()) {
// Build dialog
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(mContext);
alertDialogBuilder.setTitle(R.string.menu_whitelists);
alertDialogBuilder.setIcon(mContext.getThemed(R.attr.icon_launcher));
if (mListWhitelist.keySet().size() > 0) {
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View llWhitelists = inflater.inflate(R.layout.whitelists, null);
int index = 0;
int selected = -1;
final List<String> localizedType = new ArrayList<String>();
for (String type : mListWhitelist.keySet()) {
String name = "whitelist_" + type.toLowerCase().replace("/", "");
int id = mContext.getResources().getIdentifier(name, "string", mContext.getPackageName());
if (id == 0)
localizedType.add(name);
else
localizedType.add(mContext.getResources().getString(id));
if (type.equals(mType))
selected = index;
index++;
}
Spinner spWhitelistType = (Spinner) llWhitelists.findViewById(R.id.spWhitelistType);
ArrayAdapter<String> whitelistTypeAdapter = new ArrayAdapter<String>(mContext, android.R.layout.simple_spinner_dropdown_item, localizedType);
spWhitelistType.setAdapter(whitelistTypeAdapter);
spWhitelistType.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
mWhitelistAdapter.setType(mListWhitelist.keySet().toArray(new String[0])[position]);
}
@Override
public void onNothingSelected(AdapterView<?> view) {
}
});
if (selected >= 0)
spWhitelistType.setSelection(selected);
ListView lvWhitelist = (ListView) llWhitelists.findViewById(R.id.lvWhitelist);
lvWhitelist.setAdapter(mWhitelistAdapter);
int position = spWhitelistType.getSelectedItemPosition();
if (position != AdapterView.INVALID_POSITION)
mWhitelistAdapter.setType(mListWhitelist.keySet().toArray(new String[0])[position]);
alertDialogBuilder.setView(llWhitelists);
}
alertDialogBuilder.setPositiveButton(mContext.getString(R.string.msg_done), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// Do nothing
}
});
// Show dialog
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
}
super.onPostExecute(result);
}
use of android.widget.ArrayAdapter in project Android-GoogleDirectionAndPlaceLibrary by akexorcist.
the class PlaceActivity3 method onCreate.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_place_1);
textStatus = (TextView) findViewById(R.id.textStatus);
listView = (ListView) findViewById(R.id.listView);
gp = new GooglePlaceSearch(ApiKey);
gp.setOnPlaceResponseListener(new OnPlaceResponseListener() {
public void onResponse(String status, ArrayList<ContentValues> arr_data, Document doc) {
textStatus.setText("Status : " + status);
if (status.equals(GooglePlaceSearch.STATUS_OK)) {
ArrayList<String> array = new ArrayList<String>();
final ArrayList<String> array_photo = new ArrayList<String>();
for (int i = 0; i < arr_data.size(); i++) {
array.add("Name : " + arr_data.get(i).getAsString(GooglePlaceSearch.PLACE_NAME) + "\n" + "Address : " + arr_data.get(i).getAsString(GooglePlaceSearch.PLACE_ADDRESS) + "\n" + "Latitude : " + arr_data.get(i).getAsString(GooglePlaceSearch.PLACE_LATITUDE) + "\n" + "Longitude : " + arr_data.get(i).getAsString(GooglePlaceSearch.PLACE_LONGITUDE) + "\n" + "Phone Number : " + arr_data.get(i).getAsString(GooglePlaceSearch.PLACE_PHONENUMBER));
array_photo.add(arr_data.get(i).getAsString(GooglePlaceSearch.PLACE_PHOTO));
}
ArrayAdapter<String> adapter = new ArrayAdapter<String>(PlaceActivity3.this, R.layout.listview_text, array);
listView.setAdapter(adapter);
listView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
Dialog dialog = new Dialog(PlaceActivity3.this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.dialog_photo);
dialog.setCancelable(true);
final ImageView imgPhoto = (ImageView) dialog.findViewById(R.id.imgPhoto);
dialog.show();
gp.getPhotoBitmapByWidth(array_photo.get(arg2), 600, "", new OnBitmapResponseListener() {
public void onResponse(Bitmap bm, String tag) {
imgPhoto.setImageBitmap(bm);
}
});
}
});
}
}
});
gp.getNearby(latitude, longitude, radius, type, language, keyword);
}
use of android.widget.ArrayAdapter in project LuaViewSDK by alibaba.
the class DemoActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//初始化
init();
final ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_expandable_list_item_1, getData());
getListView().setAdapter(adapter);
getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
final String fileName = adapter.getItem(position - getListView().getHeaderViewsCount());
final Intent intent = new Intent(DemoActivity.this, DemoLuaViewActivity.class);
intent.putExtra(Constants.PARAM_URI, getFolderName() + "/" + fileName);
startActivity(intent);
}
});
}
Aggregations