Example usage for android.widget ScrollView addView

List of usage examples for android.widget ScrollView addView

Introduction

In this page you can find the example usage for android.widget ScrollView addView.

Prototype

@Override
    public void addView(View child) 

Source Link

Usage

From source file:Main.java

public static Dialog confirm(String title, View view, Context context,
        DialogInterface.OnClickListener onConfirmListener) {
    Builder dialogBuilder = confirmBuilder(title, context, onConfirmListener).setView(view);

    if (view instanceof TextView) {
        ScrollView scrollView = new ScrollView(context);
        scrollView.addView(view);
        dialogBuilder.setView(scrollView);
    }/* w w  w .  ja  va  2s  .co  m*/

    AlertDialog dialog = dialogBuilder.create();

    if (view instanceof EditText) {
        dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE
                | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    }

    dialog.show();
    return dialog;
}

From source file:cc.metapro.openct.utils.ActivityUtils.java

public static AlertDialog addViewToAlertDialog(@NonNull final AlertDialog.Builder builder,
        @NonNull final View view) {
    ViewGroup parent = (ViewGroup) view.getParent();
    if (parent != null) {
        parent.removeView(view);//  w  w w.j  ava2s.  co m
    }

    ScrollView scrollView = new ScrollView(builder.getContext());
    scrollView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    scrollView.addView(view);

    builder.setOnDismissListener(new DialogInterface.OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialog) {
            InputMethodManager imm = (InputMethodManager) builder.getContext()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
        }
    });

    AlertDialog dialog = builder.setView(scrollView).create();
    Window window = dialog.getWindow();
    if (window != null) {
        window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    }
    return dialog;
}

From source file:org.ligi.android.dubwise_uavtalk.dashboard.DownloadDashboardImagesStatusAlertDialog.java

/**
 * //from w  ww  .  j a v  a  2 s.  co m
 * @param activity
 * @param autoclose - if the alert should close when connection is established
 * 
 */
public static void show(Context activity, boolean autoclose, Intent after_connection_intent) {

    LinearLayout lin = new LinearLayout(activity);
    lin.setOrientation(LinearLayout.VERTICAL);

    ScrollView sv = new ScrollView(activity);
    TextView details_text_view = new TextView(activity);

    LinearLayout lin_in_scrollview = new LinearLayout(activity);
    lin_in_scrollview.setOrientation(LinearLayout.VERTICAL);
    sv.addView(lin_in_scrollview);
    lin_in_scrollview.addView(details_text_view);

    details_text_view.setText("no text");

    ProgressBar progress = new ProgressBar(activity, null, android.R.attr.progressBarStyleHorizontal);
    progress.setMax(img_lst.length);

    lin.addView(progress);
    lin.addView(sv);

    new AlertDialog.Builder(activity).setTitle("Download Status").setView(lin)
            .setPositiveButton("OK", new DialogDiscardingOnClickListener()).show();

    class AlertDialogUpdater implements Runnable {

        private Handler h = new Handler();
        private TextView myTextView;
        private ProgressBar myProgress;

        public AlertDialogUpdater(TextView ab, ProgressBar progress) {
            myTextView = ab;
            myProgress = progress;

        }

        public void run() {

            for (int i = 0; i < img_lst.length; i++) {
                class MsgUpdater implements Runnable {

                    private int i;

                    public MsgUpdater(int i) {
                        this.i = i;
                    }

                    public void run() {
                        myProgress.setProgress(i + 1);
                        if (i != img_lst.length - 1)
                            myTextView.setText("Downloading " + img_lst[i] + ".png");
                        else
                            myTextView.setText("Ready - please restart DUBwise to apply changes!");
                    }
                }
                h.post(new MsgUpdater(i));

                try {
                    URLConnection ucon = new URL(url_lst[i]).openConnection();
                    BufferedInputStream bis = new BufferedInputStream(ucon.getInputStream());

                    ByteArrayBuffer baf = new ByteArrayBuffer(50);
                    int current = 0;
                    while ((current = bis.read()) != -1)
                        baf.append((byte) current);

                    File path = new File(
                            Environment.getExternalStorageDirectory() + "/dubwise/images/dashboard");
                    path.mkdirs();

                    FileOutputStream fos = new FileOutputStream(
                            new File(path.getAbsolutePath() + "/" + img_lst[i] + ".png"));
                    fos.write(baf.toByteArray());
                    fos.close();
                } catch (Exception e) {
                }

                try {
                    Thread.sleep(199);
                } catch (InterruptedException e) {
                }

            }
        }
    }

    new Thread(new AlertDialogUpdater(details_text_view, progress)).start();
}

From source file:net.naonedbus.utils.InfoDialogUtils.java

/**
 * Afficher une dialog avec un contenu au format HTML
 * //w w w .  j  a  v a 2 s  .c  om
 * @param context
 * @param html
 */
public static void showHtml(final Context context, final String html) {
    AlertDialog.Builder moreDetailsDialog = null;
    final WebView webView = new WebView(context);
    final ScrollView scrollView = new ScrollView(context);

    webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    webView.setBackgroundColor(Color.WHITE);
    webView.loadDataWithBaseURL("fake://not/needed", html, "text/html", "UTF-8", null); // Encoding
    // fix
    // for
    // Android
    // 3.x
    // /
    // 4.x
    scrollView.addView(webView);

    moreDetailsDialog = new AlertDialog.Builder(context);
    moreDetailsDialog.setIcon(android.R.drawable.ic_dialog_info);
    moreDetailsDialog.setTitle("Informations");
    moreDetailsDialog.setView(scrollView);
    moreDetailsDialog.setPositiveButton(android.R.string.ok, null);
    moreDetailsDialog.show();
}

From source file:de.spiritcroc.modular_remote.Util.java

public static View scrollView(View view) {
    ScrollView scrollView = new ScrollView(view.getContext());
    scrollView.addView(view);
    return scrollView;
}

From source file:cc.softwarefactory.lokki.android.fragments.HelpFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    TextView textView = new TextView(getActivity());
    textView.setPadding(15, 15, 15, 15);
    textView.setMovementMethod(LinkMovementMethod.getInstance());

    ScrollView scroller = new ScrollView(getActivity());
    scroller.addView(textView);

    return scroller;
}

From source file:org.solovyev.android.messenger.wizard.BaseWizardStep.java

@Nonnull
protected View inflateView(int layoutResId) {
    final View view = LayoutInflater.from(getActivity()).inflate(layoutResId, null);

    final ScrollView scrollView = new ScrollView(getActivity());
    scrollView.addView(view);
    return scrollView;
}

From source file:com.connectsdk.smarthomesampler.dialog.AcknowledgementsFragmentDialog.java

@NonNull
@Override//  www . ja  v  a 2  s .  co m
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Context context = getActivity();
    final TextView message = new TextView(context);
    message.setText(Html.fromHtml(context.getString(R.string.info_message)));
    message.setMovementMethod(LinkMovementMethod.getInstance());
    int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 25,
            context.getResources().getDisplayMetrics());
    message.setPadding(padding, 0, padding, 0);
    ScrollView scrollView = new ScrollView(context);
    scrollView.addView(message);

    return new AlertDialog.Builder(context).setTitle(R.string.info_title).setView(scrollView)
            .setCancelable(true).create();
}

From source file:ar.rulosoft.mimanganu.LicenseFragment.java

@Nullable
@Override//w w w  .  j  a v a 2  s.co  m
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    setHasOptionsMenu(true);
    setRetainInstance(true);
    mLicenseView = new TextView(getActivity());
    //        mLicenseView.setTextAppearance(getActivity(), android.R.style.TextAppearance_Medium);
    mLicenseView.setPadding(10, 10, 10, 10);
    if (!MainActivity.darkTheme) {
        mLicenseView.setTextColor(ContextCompat.getColor(getContext(), black));
    }
    ScrollView newScroll = new ScrollView(getActivity());
    newScroll.addView(mLicenseView);
    return newScroll;
}

From source file:com.slushpupie.deskclock.ChangelogDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    // Standard AlertDialog does not support HTML-style links.
    // So rebuild the ScrollView->TextView with the appropriate
    // settings and set the view directly.
    TextView tv = new TextView(getActivity());
    tv.setPadding(5, 5, 5, 5);/*from w  ww .  j  a  v  a  2s.co m*/
    tv.setLinksClickable(true);
    tv.setMovementMethod(LinkMovementMethod.getInstance());
    tv.setText(R.string.changeLog);
    tv.setTextAppearance(getActivity(), android.R.style.TextAppearance_Medium);
    ScrollView sv = new ScrollView(getActivity());
    sv.setPadding(14, 2, 10, 12);
    sv.addView(tv);
    builder.setView(sv).setCancelable(false).setTitle(R.string.changeLogTitle).setPositiveButton(R.string.ok,
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    ((DeskClock) getActivity()).acknoledgeChangelog();
                }
            });
    return builder.create();
}