本文整理汇总了Java中com.afollestad.materialdialogs.simplelist.MaterialSimpleListAdapter类的典型用法代码示例。如果您正苦于以下问题:Java MaterialSimpleListAdapter类的具体用法?Java MaterialSimpleListAdapter怎么用?Java MaterialSimpleListAdapter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MaterialSimpleListAdapter类属于com.afollestad.materialdialogs.simplelist包,在下文中一共展示了MaterialSimpleListAdapter类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showSimpleList
import com.afollestad.materialdialogs.simplelist.MaterialSimpleListAdapter; //导入依赖的package包/类
@OnClick(R.id.simpleList) public void showSimpleList() {
final MaterialSimpleListAdapter adapter = new MaterialSimpleListAdapter((dialog, index1, item) -> showToast(item.getContent().toString()));
adapter.add(new MaterialSimpleListItem.Builder(this)
.content("[email protected]")
.icon(R.drawable.ic_account_circle)
.backgroundColor(Color.WHITE)
.build());
adapter.add(new MaterialSimpleListItem.Builder(this)
.content("[email protected]")
.icon(R.drawable.ic_account_circle)
.backgroundColor(Color.WHITE)
.build());
adapter.add(new MaterialSimpleListItem.Builder(this)
.content(R.string.add_account)
.icon(R.drawable.ic_content_add)
.iconPaddingDp(8)
.build());
new MaterialDialog.Builder(this)
.title(R.string.set_backup)
.adapter(adapter, null)
.show();
}
示例2: showSimpleList
import com.afollestad.materialdialogs.simplelist.MaterialSimpleListAdapter; //导入依赖的package包/类
@OnClick(R.id.simpleList)
public void showSimpleList() {
final MaterialSimpleListAdapter adapter =
new MaterialSimpleListAdapter(
(dialog, index1, item) -> showToast(item.getContent().toString()));
adapter.add(
new MaterialSimpleListItem.Builder(this)
.content("[email protected]")
.icon(R.drawable.ic_account_circle)
.backgroundColor(Color.WHITE)
.build());
adapter.add(
new MaterialSimpleListItem.Builder(this)
.content("[email protected]")
.icon(R.drawable.ic_account_circle)
.backgroundColor(Color.WHITE)
.build());
adapter.add(
new MaterialSimpleListItem.Builder(this)
.content(R.string.add_account)
.icon(R.drawable.ic_content_add)
.iconPaddingDp(8)
.build());
new MaterialDialog.Builder(this).title(R.string.set_backup).adapter(adapter, null).show();
}
示例3: onBuildLongClicked
import com.afollestad.materialdialogs.simplelist.MaterialSimpleListAdapter; //导入依赖的package包/类
@Override
public void onBuildLongClicked(final BuildViewHolder buildViewHolder) {
Context context = getActivity();
final MaterialSimpleListAdapter adapter = new MaterialSimpleListAdapter(new MaterialSimpleListAdapter.Callback() {
@Override
public void onMaterialListItemSelected(MaterialDialog dialog, int index, MaterialSimpleListItem item) {
long buildId = buildViewHolder.viewModel.getBuildId();
switch (index) {
case 0:
editBuild(buildId);
break;
case 1:
confirmDeleteBuild(buildId);
break;
case 2:
exportBuild(buildId);
break;
default:
Timber.e("Unknown context menu item selected, index = " + index);
break;
}
dialog.dismiss();
}
});
adapter.add(new MaterialSimpleListItem.Builder(context)
.content(R.string.menu_edit_build)
.build());
adapter.add(new MaterialSimpleListItem.Builder(context)
.content(R.string.menu_delete_build)
.build());
adapter.add(new MaterialSimpleListItem.Builder(context)
.content(R.string.menu_export_build)
.build());
new MaterialDialog.Builder(context)
.title(buildViewHolder.viewModel.getName())
.adapter(adapter, null)
.show();
}
示例4: list
import com.afollestad.materialdialogs.simplelist.MaterialSimpleListAdapter; //导入依赖的package包/类
@ReactMethod
public void list(ReadableMap options, final Callback callback) {
final MaterialSimpleListAdapter simpleListAdapter = new MaterialSimpleListAdapter(getCurrentActivity());
ReadableArray arr = options.getArray("items");
for(int i = 0; i < arr.size(); i++){
simpleListAdapter.add(new MaterialSimpleListItem.Builder(getCurrentActivity())
.content(arr.getString(i))
.build());
}
final MaterialDialog.Builder adapter = new MaterialDialog.Builder(getCurrentActivity())
.title(options.hasKey("title") ? options.getString("title") : "")
.adapter(simpleListAdapter, new MaterialDialog.ListCallback() {
@Override
public void onSelection(MaterialDialog dialog, View itemView, int which, CharSequence text) {
callback.invoke(which, text);
if (simple != null) {
simple.dismiss();
}
}
})
.autoDismiss(true);
UiThreadUtil.runOnUiThread(new Runnable() {
public void run() {
if (simple != null) {
simple.dismiss();
}
simple = adapter.build();
simple.show();
}
});
}
示例5: showProFeatures
import com.afollestad.materialdialogs.simplelist.MaterialSimpleListAdapter; //导入依赖的package包/类
public static MaterialDialog showProFeatures(final Context context) {
final MaterialSimpleListAdapter adapter = new MaterialSimpleListAdapter(context);
adapter.add(new MaterialSimpleListItem.Builder(context)
.content(context.getResources().getString(R.string.pro_feature_1))
.icon(new IconicsDrawable(context).icon(GoogleMaterial.Icon.gmd_visibility_off).color(Color.GRAY).sizeDp(18))
.backgroundColor(Color.WHITE)
.build());
adapter.add(new MaterialSimpleListItem.Builder(context)
.content(context.getResources().getString(R.string.pro_feature_2))
.icon(new IconicsDrawable(context).icon(GoogleMaterial.Icon.gmd_list).color(Color.GRAY).sizeDp(18))
.backgroundColor(Color.WHITE)
.build());
adapter.add(new MaterialSimpleListItem.Builder(context)
.content(context.getResources().getString(R.string.pro_feature_3))
.icon(new IconicsDrawable(context).icon(GoogleMaterial.Icon.gmd_phonelink_erase).color(Color.GRAY).sizeDp(18))
.backgroundColor(Color.WHITE)
.build());
adapter.add(new MaterialSimpleListItem.Builder(context)
.content(context.getResources().getString(R.string.pro_feature_4))
.icon(new IconicsDrawable(context).icon(GoogleMaterial.Icon.gmd_delete).color(Color.GRAY).sizeDp(18))
.backgroundColor(Color.WHITE)
.build());
MaterialDialog.Builder materialBuilder = new MaterialDialog.Builder(context)
.title(context.getResources().getString(R.string.action_buy) + " (" + context.getResources().getString(R.string.action_buy_description) + ")")
.icon(ContextCompat.getDrawable(context, R.mipmap.ic_launcher_pro))
.adapter(adapter, new MaterialDialog.ListCallback() {
@Override
public void onSelection(MaterialDialog materialDialog, View view, int i, CharSequence charSequence) {}
})
.positiveText(context.getResources().getString(R.string.action_buy) + " ($1.43)")
.negativeText(context.getResources().getString(R.string.button_later))
.onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
UtilsApp.goToGooglePlay(context, MLManagerApplication.getProPackage());
}
});
return materialBuilder.show();
}
示例6: onClick
import com.afollestad.materialdialogs.simplelist.MaterialSimpleListAdapter; //导入依赖的package包/类
public void onClick() {
TextContentView textContent = mBalloonTheme.getTextContentView();
if (textContent == null)
return;
// Check for links. If none, do nothing; if 1, open it; if >1, ask user to pick one
final URLSpan[] spans = textContent.getUrls();
if (spans.length == 0) {
// show the message details dialog
MessageUtils.showMessageDetails(getContext(), mMessage, mPeer, mDisplayName);
}
else if (spans.length == 1) {
// show link opener
spans[0].onClick(textContent);
}
else {
// complex stuff (media)
URLSpanAdapterCallback click = new URLSpanAdapterCallback(textContent);
final MaterialSimpleListAdapter adapter = new MaterialSimpleListAdapter(click);
for (URLSpan span : spans) {
MaterialSimpleListItem.Builder builder = new MaterialSimpleListItem.Builder(getContext())
.tag(span);
try {
String url = span.getURL();
Uri uri = Uri.parse(url);
final String telPrefix = "tel:";
if (url.startsWith(telPrefix)) {
// TODO handle country code
url = url.substring(telPrefix.length());
}
builder.content(url);
Drawable d = getContext().getPackageManager().getActivityIcon(
new Intent(Intent.ACTION_VIEW, uri));
if (d != null) {
builder.icon(d).iconPadding(10);
}
}
catch (android.content.pm.PackageManager.NameNotFoundException ex) {
// it's ok if we're unable to set the drawable for this view - the user
// can still use it
}
adapter.add(builder.build());
}
new MaterialDialog.Builder(getContext())
.title(R.string.chooser_select_link)
.cancelable(true)
.adapter(adapter, null)
.negativeText(android.R.string.cancel)
.onNegative(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
dialog.dismiss();
}
})
.show();
}
}