android.app.AlertDialog#getLayoutInflater ( )源码实例Demo

下面列出了android.app.AlertDialog#getLayoutInflater ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

private AlertDialog createAlertDialog(Context context, UpdateInfo updateInfo) {
  final FrameLayout frameView = new FrameLayout(context);
  builder.setView(frameView);

  final AlertDialog alertDialog = builder.create();
  LayoutInflater inflater = alertDialog.getLayoutInflater();
  inflater.inflate(R.layout.applivery_suggested_update, frameView);
  TextView textView = frameView.findViewById(R.id.suggested_update_text);

  String appliveryUpdateMsg = context.getString(R.string.appliveryUpdateMsg);

  if (!appliveryUpdateMsg.isEmpty()) {
    textView.setText(appliveryUpdateMsg);
  } else {
    if (updateInfo != null) {
      textView.setText(updateInfo.getAppUpdateMessage());
    }
  }
  return alertDialog;
}
 
源代码2 项目: ThinDownloadManager   文件: MainActivity.java
private void showInternalFilesDir() {
    File internalFile = new File(getExternalFilesDir("").getPath());
    File files[] = internalFile.listFiles();
    StringBuilder contentText = new StringBuilder();
    if( files.length == 0 ) {
        contentText = new StringBuilder("No Files Found");
    }

    for (File file : files) {
        contentText.append(file.getName()).append(" ").append(file.length()).append(" \n\n ");
    }

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    AlertDialog internalCacheDialog = builder.create();
    LayoutInflater inflater = internalCacheDialog.getLayoutInflater();
    View dialogLayout = inflater.inflate(R.layout.layout_files, null);
    TextView content = (TextView) dialogLayout.findViewById(R.id.filesList);
    content.setText(contentText.toString());

    builder.setView(dialogLayout);
    builder.show();

}