Example usage for android.widget LinearLayout addView

List of usage examples for android.widget LinearLayout addView

Introduction

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

Prototype

public void addView(View child) 

Source Link

Document

Adds a child view.

Usage

From source file:Main.java

public static void addDot2Layout(LinearLayout ll_dot, ImageView[] ivDots) {
    for (ImageView iv : ivDots) {
        ll_dot.addView(iv);
    }//from   ww w  . j av a  2s. c  o  m
}

From source file:Main.java

public static Button setActionButton(Context context, LinearLayout linearLayout, View.OnClickListener l) {
    Button b = new Button(context);
    b.setText("Click");
    linearLayout.addView(b);
    b.setOnClickListener(l);//from  w  ww . j a  v a  2 s.c  o m
    return b;
}

From source file:Main.java

public static void addSpacer(Activity activity, LinearLayout layout, String sp, int size) {
    TextView mSpacer = new TextView(activity);
    mSpacer.setTextSize(size);//  w  ww  .j ava  2 s. c o m
    mSpacer.setText(sp);
    layout.addView(mSpacer);

}

From source file:Main.java

public static LinearLayout setProgressBarLayout(Activity activity) {

    LinearLayout progressBarLayout = new LinearLayout(activity);
    progressBarLayout.setGravity(Gravity.CENTER);
    ProgressBar spinner = new ProgressBar(activity);
    progressBarLayout.addView(spinner);
    activity.addContentView(progressBarLayout,
            new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

    return progressBarLayout;
}

From source file:Main.java

public static void addStars(int cre, LinearLayout container, Activity activity, int drawableResId) {
    container.removeAllViews();//from w  ww. j  a  va2 s.c o m
    int num = (int) Math.round(cre * 1.0 / 10);
    for (int i = 0; i < num; i++) {
        container.addView(newStar(activity, drawableResId));
    }
}

From source file:Main.java

private static void addCount(Activity activity, Integer count, LinearLayout layout, String label) {
    if (count != null && count > 0) {
        TextView amt = new TextView(activity);
        amt.setTextSize(textSize);//from   w  w w .j a  va2  s  .  c  om
        amt.setText(count.toString() + " " + label + "  ");
        layout.addView(amt);
    }
}

From source file:Main.java

private static void addText(Activity activity, String text, LinearLayout layout, int maxWidth) {
    TextView textView = new TextView(activity);
    textView.setTextSize(textSize);/*  www. ja va2  s  .  c o m*/
    textView.setMaxWidth(maxWidth);
    textView.setEllipsize(TextUtils.TruncateAt.END);
    textView.setText(text + "  ");
    layout.addView(textView);

}

From source file:Main.java

private static LinearLayout createLLforAddToCalendar(final Context context, final CheckBox checkBox) {

    LinearLayout linearLayout = new LinearLayout(context);
    linearLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.MATCH_PARENT));
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    linearLayout.addView(checkBox);
    return linearLayout;
}

From source file:Main.java

public static void addResourceImage(Activity activity, LinearLayout layout, int imgResource, int width,
        int height) {
    ImageView image = new ImageView(activity);
    image.setImageResource(imgResource);
    if (width > 0)
        image.setMaxWidth(width);//from   w ww  .  ja  va  2 s  . c  o  m
    if (height > 0)
        image.setMaxHeight(height);
    image.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    layout.addView(image);
}

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

/**
 * /*from w  w  w.j a v  a  2 s.c  o 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();
}