当前位置: 首页>>代码示例>>Java>>正文


Java Snackbar.setDuration方法代码示例

本文整理汇总了Java中android.support.design.widget.Snackbar.setDuration方法的典型用法代码示例。如果您正苦于以下问题:Java Snackbar.setDuration方法的具体用法?Java Snackbar.setDuration怎么用?Java Snackbar.setDuration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.design.widget.Snackbar的用法示例。


在下文中一共展示了Snackbar.setDuration方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: showPositive

import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
public static void showPositive(Activity activity, String message) {
    Snackbar snackbar = Snackbar.make(activity.findViewById(R.id.fab), message, Snackbar.LENGTH_LONG);
    View sbView = snackbar.getView();
    TextView textView = (TextView) sbView.findViewById(android.support.design.R.id.snackbar_text);
    textView.setTextColor(Color.GREEN);
    snackbar.setDuration(3*1000);
    snackbar.show();
}
 
开发者ID:lvaccaro,项目名称:BitcoinBlockExplorer,代码行数:9,代码来源:MySnackbar.java

示例2: showNegative

import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
public static void showNegative(Activity activity, String message) {
    Snackbar snackbar = Snackbar.make(activity.findViewById(R.id.fab), message, Snackbar.LENGTH_LONG);
    View sbView = snackbar.getView();
    TextView textView = (TextView) sbView.findViewById(android.support.design.R.id.snackbar_text);
    textView.setTextColor(Color.RED);
    snackbar.setDuration(3*1000);
    snackbar.show();
}
 
开发者ID:lvaccaro,项目名称:BitcoinBlockExplorer,代码行数:9,代码来源:MySnackbar.java

示例3: showWarning

import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
public static void showWarning(Activity activity, String message) {
    Snackbar snackbar = Snackbar.make(activity.findViewById(R.id.fab), message, Snackbar.LENGTH_LONG);
    View sbView = snackbar.getView();
    TextView textView = (TextView) sbView.findViewById(android.support.design.R.id.snackbar_text);
    textView.setTextColor(Color.YELLOW);
    snackbar.setDuration(3*1000);
    snackbar.show();
}
 
开发者ID:lvaccaro,项目名称:BitcoinBlockExplorer,代码行数:9,代码来源:MySnackbar.java

示例4: showSnack

import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
private void showSnack(String message) {
    Snackbar snackbar = Snackbar.make(findViewById(R.id.fab), message, Snackbar.LENGTH_LONG);

    View sbView = snackbar.getView();
    TextView textView = (TextView) sbView.findViewById(android.support.design.R.id.snackbar_text);
    snackbar.setDuration(10*1000);
    snackbar.show();
}
 
开发者ID:lvaccaro,项目名称:BitcoinBlockExplorer,代码行数:9,代码来源:MainActivity.java

示例5: make

import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
@Implementation
public static Snackbar make(@NonNull View view, @NonNull CharSequence text, int duration) {
    Snackbar snackbar = null;

    try {
        Constructor<Snackbar> constructor = Snackbar.class.getDeclaredConstructor(ViewGroup.class);

        //just in case, maybe they'll change the method signature in the future
        if (null == constructor)
            throw new IllegalArgumentException("Seems like the constructor was not found!");


        if (Modifier.isPrivate(constructor.getModifiers())) {
            constructor.setAccessible(true);
        }

        snackbar = constructor.newInstance(findSuitableParent(view));
        snackbar.setText(text);
        snackbar.setDuration(duration);
    } catch (Exception e) {
        e.printStackTrace();
    }

    shadowOf(snackbar).text = text.toString();

    shadowSnackbars.add(shadowOf(snackbar));

    return snackbar;
}
 
开发者ID:mirhoseini,项目名称:bcg,代码行数:30,代码来源:ShadowSnackbar.java

示例6: onPostExecute

import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
@Override
protected void onPostExecute(final Pair<Integer, File> result) {
  super.onPostExecute(result);
  final Context context = contextReference.get();
  if (context == null) return;

  switch (result.first()) {
    case FAILURE:
      Toast.makeText(context,
                     context.getResources().getQuantityText(R.plurals.ConversationFragment_error_while_saving_attachments_to_sd_card,
                                                            attachmentCount),
                     Toast.LENGTH_LONG).show();
      break;
    case SUCCESS:
      Snackbar snackbar = Snackbar.make(view.get(),
                                        context.getResources().getQuantityText(R.plurals.ConversationFragment_files_saved_successfully, attachmentCount),
                                        Snackbar.LENGTH_SHORT);

      if (result.second() != null) {
        snackbar.setDuration(Snackbar.LENGTH_LONG);
        snackbar.setAction(R.string.SaveAttachmentTask_open_directory, new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setDataAndType(Uri.fromFile(result.second()), "resource/folder");
            if (intent.resolveActivityInfo(context.getPackageManager(), 0) != null)
            {
              context.startActivity(intent);
            }
          }
        });
      }

      snackbar.show();
      break;
    case WRITE_ACCESS_FAILURE:
      Toast.makeText(context, R.string.ConversationFragment_unable_to_write_to_sd_card_exclamation,
          Toast.LENGTH_LONG).show();
      break;
  }
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:42,代码来源:SaveAttachmentTask.java


注:本文中的android.support.design.widget.Snackbar.setDuration方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。