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:com.eggsoftware.flingsolver.gui.DrawSolutionPageAdapter.java

@Override
public Object instantiateItem(View collection, int position) {
    // Create the "Step N of T" TextView
    TextView stepTextView = new TextView(this.context);
    stepTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    stepTextView.setTextColor(Color.rgb(113, 113, 113));
    stepTextView.setGravity(Gravity.CENTER);
    stepTextView.setText(String.format(this.context.getResources().getString(R.string.step_of), position + 1,
            this.solution.size()));

    // Create the boar with the current step of the solution
    BoardCanvas board = new BoardCanvas(this.context);
    board.setBoardRepresentation(this.solution.get(position).getBoard());
    board.setArrow(this.solution.get(position).getRow(), this.solution.get(position).getCol(),
            this.solution.get(position).getDirection());

    // Add the components to the layout
    LinearLayout layout = new LinearLayout(this.context);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setPadding(16, 20, 16, 16);//from  w ww .ja v a 2s.c o  m

    RelativeLayout relativeLatout = new RelativeLayout(this.context);
    relativeLatout.setLayoutParams(
            new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f));
    relativeLatout.addView(board);

    layout.addView(relativeLatout);
    layout.addView(stepTextView);
    ((ViewPager) collection).addView(layout, 0);
    return layout;
}

From source file:com.jeffreyawest.weblogic.monitor.activity.display.DisplayApplicationActivity.java

@Override
public void updateDisplay(Application app) {

    super.updateDisplay(app);

    setTitle(app.getName() + " (" + app.getType() + ")");
    //app_target_state_chart_fragment

    FragmentManager fm = getSupportFragmentManager();

    ApplicationTargetStatePieChart targetStatePieChart = (ApplicationTargetStatePieChart) fm
            .findFragmentById(R.id.app_target_state_chart_fragment);
    targetStatePieChart.update(app);//  w w  w .  ja v  a 2s. co m

    LinearLayout tableContainer = (LinearLayout) DisplayApplicationActivity.this
            .findViewById(R.id.data_container);

    TextView header = new TextView(DisplayApplicationActivity.this);
    header.setTextSize(this.getResources().getDimension(R.dimen.entity_details_table_text_size));
    header.setText("Application Target States");

    TableLayout stateTable = new TableLayout(DisplayApplicationActivity.this);
    tableContainer.addView(stateTable);

    for (ApplicationTargetState state : app.getTargetStates()) {
        stateTable.addView(getRow(state.getTarget(), state.getState().toString()));
    }
}

From source file:com.polyvi.xface.extension.inappbrowser.XInAppBrowser.java

/**
 * WebView//w  w w . j  ava 2 s. c om
 * @param url WebViewurl
 * @return
 */
protected void createWebView(String url, LinearLayout mainLayout) {
    mWebView = new XInAppWebView(mContext, this, url, mWebContext);
    mainLayout.addView(mWebView);
}

From source file:com.ferasinfotech.gwreader.ScreenSlidePageFragment.java

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

    View.OnLongClickListener click_listener = new View.OnLongClickListener() {
        public boolean onLongClick(View v) {
            Intent i = new Intent(Intent.ACTION_VIEW);
            String s = "https://www.grasswire.com";

            if (mStoryID != 0) {
                s = s + "/story/" + mStoryID + "/x";
            }/*w  w w.  j a v a 2s. com*/
            i.setData(Uri.parse(s));
            i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(i);

            return true;
        }
    };

    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_screen_slide_page, container, false);

    //      Picasso.with(getActivity()).setLoggingEnabled(true);
    //      Picasso.with(getActivity()).setIndicatorsEnabled(true);
    ImageView cover_image = (ImageView) rootView.findViewById(R.id.story_image);
    Picasso.with(getActivity()).load(mCoverPhoto).into(cover_image);

    cover_image.setOnLongClickListener(click_listener);

    ((TextView) rootView.findViewById(R.id.story_title)).setText(mTitle);
    ((TextView) rootView.findViewById(R.id.story_headline)).setText(mHeadline);
    ((TextView) rootView.findViewById(R.id.story_summary)).setText(mSummary);

    Log.d("***DEBUG***", "Building page:" + mPageNumber);

    if (mStoryID != 0) {
        LinksAdapter adapter = new LinksAdapter(getActivity(), mStoryString);
        LinearLayout ll = (LinearLayout) rootView.findViewById(R.id.story_layout);
        for (int i = 0; i < adapter.getCount(); i++) {
            View listItem = adapter.getView(i, null, ll);
            ll.addView(listItem);
        }
    }

    return rootView;
}

From source file:com.endiansoftware.echo.remotewatch.GcmBroadcastReceiver.java

@Override
public void onReceive(Context context, Intent intent) {

    /*/* w w w  . jav  a  2s.  c o m*/
       // Explicitly specify that GcmIntentService will handle the intent.
    ComponentName comp = new ComponentName(context.getPackageName(),
        GcmIntentService.class.getName());
    // Start the service, keeping the device awake while it is launching.
    startWakefulService(context, (intent.setComponent(comp)));
    setResultCode(Activity.RESULT_OK);
    */

    /*
    // ?    ?? .
    Intent popupIntent = new Intent(context, Popup.class)
        .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    //  .
    context.startActivity(popupIntent);
            
    */

    LinearLayout layout = new LinearLayout(context);
    //layout.setBackgroundResource(R.color.LightOrange);

    TextView tv = new TextView(context);
    // set the TextView properties like color, size etc
    tv.setTextColor(Color.RED);
    tv.setTextSize(15);

    tv.setGravity(Gravity.CENTER_VERTICAL);

    // set the text you want to show in  Toast
    tv.setText("My Custom Toast at Bottom of Screen");

    layout.addView(tv);

    Toast toast = new Toast(context); //context is object of Context write "this" if you are an Activity
    // Set The layout as Toast View
    toast.setView(layout);

    // Position you toast here toast position is 50 dp from bottom you can give any integral value
    toast.setGravity(Gravity.BOTTOM, 0, 50);
    toast.show();
}

From source file:net.amdroid.metrosp.MetroSP.java

/** Called when the activity is first created. */
@Override/*w  ww  .  jav  a2  s. co m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);

    /* Select the configured Theme */
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    String themeStr = prefs.getString(Preferences.PREF_THEME, "White.Theme");
    int theme = getResources().getIdentifier(themeStr, "style", "net.amdroid.metrosp");
    setTheme(theme);

    setContentView(R.layout.main);

    AdView adView = new AdView(this, AdSize.BANNER, "a14d8821cfdf925");
    LinearLayout layout = (LinearLayout) findViewById(R.id.addsLayout);
    layout.addView(adView);
    AdRequest adrequest = new AdRequest();
    adView.loadAd(adrequest);

    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title);

    metroLines = new ArrayList<MetroLine>();
    int resID = R.layout.list_item;
    adapter = new MetroLineAdapter(this, resID, metroLines);

    listview = (ListView) findViewById(R.id.metroList);
    title = (TextView) findViewById(R.id.app_title);
    refresh_btn = (Button) findViewById(R.id.refresh_button);
    listview.setAdapter(adapter);

    refresh_btn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Log.d("MetroSP", "Refresh");
            refreshData();
        }
    });

    /* Setup the viewFlipper to do the slidding tab */
    viewFlipper = (ViewFlipper) findViewById(R.id.flipper);
    slideLeftIn = AnimationUtils.loadAnimation(this, R.anim.slide_left_in);
    slideLeftOut = AnimationUtils.loadAnimation(this, R.anim.slide_left_out);
    slideRightIn = AnimationUtils.loadAnimation(this, R.anim.slide_right_in);
    slideRightOut = AnimationUtils.loadAnimation(this, R.anim.slide_right_out);
    firsttab = true;

    /* Set listview OnClick Handler to show package status */
    listview.setOnItemClickListener(listviewOnClick);

    refreshData();
}

From source file:com.art2cat.dev.moonlightnote.controller.settings.CommonSettingsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    if (getArguments() != null) {
        mType = getArguments().getInt("type");
    }// w  w  w .  j av a 2  s  .  c  o m
    LinearLayout linearLayout = new LinearLayout(getActivity());
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.MATCH_PARENT);
    linearLayout.setLayoutParams(params);
    ScrollView scrollView = new ScrollView(getActivity());
    scrollView.setLayoutParams(params);
    linearLayout.addView(scrollView);
    TextView textView = new TextView(getActivity());
    textView.setLayoutParams(params);
    int padding = getResources().getDimensionPixelOffset(R.dimen.padding);
    textView.setPadding(padding, padding, padding, padding);
    switch (mType) {
    case Constants.FRAGMENT_ABOUT:
        textView.setGravity(Gravity.CENTER);
        textView.setText(getContent());
        getActivity().setTitle(R.string.settings_about);
        break;
    case Constants.FRAGMENT_LICENSE:
        textView.setGravity(Gravity.CENTER);
        textView.setText(getContent());
        getActivity().setTitle(R.string.settings_license);
        break;
    case Constants.FRAGMENT_POLICY:
        textView.setGravity(Gravity.START);
        textView.setText(getContent());
        getActivity().setTitle(R.string.settings_policy);
        break;
    }
    setHasOptionsMenu(true);
    scrollView.addView(textView);
    return linearLayout;
}

From source file:com.wellsandwhistles.android.redditsp.reddit.prepared.RedditPreparedMessage.java

@Override
public View getBody(final AppCompatActivity activity, final Integer textColor, final Float textSize,
        final boolean showLinkButtons) {

    final LinearLayout subjectLayout = new LinearLayout(activity);
    subjectLayout.setOrientation(LinearLayout.VERTICAL);

    final TextView subjectText = new TextView(activity);
    subjectText.setText(StringEscapeUtils.unescapeHtml4(src.subject != null ? src.subject : "(no subject)"));
    subjectText.setTextColor(textColor);
    subjectText.setTextSize(textSize);//from  ww w . jav  a2  s.c  o  m
    subjectText.setTypeface(null, Typeface.BOLD);

    subjectLayout.addView(subjectText);
    subjectLayout.addView(body.buildView(activity, textColor, textSize, showLinkButtons));

    return subjectLayout;
}

From source file:com.krayzk9s.imgurholo.ui.MessagingFragment.java

private void buildSendMessage(String username) {
    ImgurHoloActivity activity = (ImgurHoloActivity) getActivity();
    final EditText newUsername = new EditText(activity);
    newUsername.setSingleLine();//from   w w  w  .  ja v a 2s  . co m
    newUsername.setHint(R.string.body_hint_recipient);
    if (username != null)
        newUsername.setText(username);
    final EditText newBody = new EditText(activity);
    newBody.setHint(R.string.body_hint_body);
    newBody.setLines(5);
    LinearLayout linearLayout = new LinearLayout(activity);
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    linearLayout.addView(newUsername);
    linearLayout.addView(newBody);
    new AlertDialog.Builder(activity).setTitle(R.string.dialog_send_message_title).setView(linearLayout)
            .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    MessagingAsync messagingAsync = new MessagingAsync(newBody.getText().toString(),
                            newUsername.getText().toString());
                    messagingAsync.execute();

                }
            }).setNegativeButton(R.string.dialog_answer_cancel, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    // Do nothing.
                }
            }).show();
}

From source file:com.cyanogenmod.settings.otgtoggle.OtgModeChooserActivity.java

private void inflateOption(final int titleResId, final int summaryResId, int mode, int currentMode,
        LinearLayout container) {
    View v = mLayoutInflater.inflate(R.layout.radio_with_summary, container, false);
    CheckedTextView title = (CheckedTextView) v.findViewById(android.R.id.title);
    TextView summary = (TextView) v.findViewById(android.R.id.summary);

    title.setText(titleResId);/*from w  w  w  . j av a 2s  .  c om*/
    title.setChecked(mode == currentMode);
    summary.setText(summaryResId);

    v.setTag(mode);
    v.setOnClickListener(this);
    container.addView(v);
}