List of usage examples for android.widget ListView ListView
public ListView(Context context)
From source file:com.nttec.everychan.ui.presentation.BoardFragment.java
private void openReferencesList(final String from) { final List<Integer> positions = new ArrayList<>(); int position = -1; for (int i = 0; i < presentationModel.presentationList.size(); ++i) { if (presentationModel.presentationList.get(i).sourceModel.number.equals(from)) { position = i;//w w w . j a va 2 s .co m break; } } if (position != -1) { Spanned referencesString = presentationModel.presentationList.get(position).referencesString; if (referencesString == null) { Logger.e(TAG, "null referencesString"); return; } ClickableURLSpan[] spans = referencesString.getSpans(0, referencesString.length(), ClickableURLSpan.class); for (ClickableURLSpan span : spans) { String url = span.getURL(); try { //url , .. ??? PresentationItemModel ( ) UrlPageModel model = UrlHandler.getPageModel(url); for (; position < presentationModel.presentationList.size(); ++position) { if (presentationModel.presentationList.get(position).sourceModel.number .equals(model.postNumber)) { break; } } if (position < presentationModel.presentationList.size()) positions.add(position); } catch (Exception e) { Logger.e(TAG, e); } } } if (positions.size() == 0) { Logger.e(TAG, "no references"); return; } final int bgShadowResource = ThemeUtils.getThemeResId(activity.getTheme(), R.attr.dialogBackgroundShadow); final int bgColor = ThemeUtils.getThemeColor(activity.getTheme(), R.attr.activityRootBackground, Color.BLACK); final View tmpV = new View(activity); final Dialog tmpDlg = new Dialog(activity); tmpDlg.getWindow().setBackgroundDrawableResource(bgShadowResource); tmpDlg.requestWindowFeature(Window.FEATURE_NO_TITLE); tmpDlg.setCanceledOnTouchOutside(true); tmpDlg.setContentView(tmpV); tmpDlg.show(); Runnable next = new Runnable() { @Override public void run() { final int dlgWidth = tmpV.getWidth(); tmpDlg.hide(); tmpDlg.cancel(); ListView dlgList = new ListView(activity); dlgList.setAdapter(new ArrayAdapter<Integer>(activity, 0, positions) { @Override public View getView(int position, View convertView, ViewGroup parent) { try { int adapterPositon = getItem(position); View view = adapter.getView(adapterPositon, convertView, parent, dlgWidth, adapter.getItem(adapterPositon), from); view.setBackgroundColor(bgColor); return view; } catch (Exception e) { Logger.e(TAG, e); Toast.makeText(activity, R.string.error_unknown, Toast.LENGTH_LONG).show(); return new View(activity); } } }); Dialog dialog = new Dialog(activity); dialog.getWindow().setBackgroundDrawableResource(bgShadowResource); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCanceledOnTouchOutside(true); dialog.setContentView(dlgList); dialog.show(); dialogs.add(dialog); } }; if (tmpV.getWidth() != 0) { next.run(); } else { AppearanceUtils.callWhenLoaded(tmpDlg.getWindow().getDecorView(), next); } }