Example usage for android.widget LinearLayout VERTICAL

List of usage examples for android.widget LinearLayout VERTICAL

Introduction

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

Prototype

int VERTICAL

To view the source code for android.widget LinearLayout VERTICAL.

Click Source Link

Usage

From source file:cz.metaverse.android.bilingualreader.ReaderActivity.java

/**
 * Called when the device configuration changes.
 *//*  www.  ja  v a 2  s  .  c  om*/
@Override
public void onConfigurationChanged(Configuration newConfig) {
    Log.d(LOG, LOG + ".onConfigurationChanged");
    super.onConfigurationChanged(newConfig);

    // Signal to the Governor that a runtime change has occurred.
    governor.onRuntimeChange();

    // Change the orientation of the PanelsLayout accordingly.
    LinearLayout panelsLayout = (LinearLayout) findViewById(R.id.PanelsLayout);
    if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
        panelsLayout.setOrientation(LinearLayout.VERTICAL);
    } else {
        panelsLayout.setOrientation(LinearLayout.HORIZONTAL);
    }

    // Set the divider again, because it needs to be redrawn due to the orientation change.
    panelsLayout.setDividerDrawable(ContextCompat.getDrawable(this, R.drawable.divider_panels));

    // Inform ActionBar Drawer Toggle of the change.
    actionBarDrawerToggle.onConfigurationChanged(newConfig);
}

From source file:com.example.fragmentdemo.views.PagerSlidingTabStrip.java

private void addTab(final int position, CharSequence title, int iconResId, int iLayoutResId, int iTextId,
        int iIconLocation) {
    // final View tabView = ((Activity) getContext()).getLayoutInflater()
    // .inflate(iLayoutResId, null);
    // TextView tab_text_textview = (TextView)
    // tabView.findViewById(iTextId);
    // tab_text_textview.setText(title);
    LinearLayout tabView = new LinearLayout(getContext());
    tabView.setGravity(Gravity.CENTER);/*from  w  w  w.j a v  a 2  s .  c o  m*/
    TextView tab_text_textview = new TextView(getContext());
    tab_text_textview.setId(position);
    tab_text_textview.setText(title);
    tab_text_textview.setGravity(Gravity.CENTER_VERTICAL);
    tab_text_textview.setSingleLine();
    // tab_text_textview.setTextColor(tabTextColor);
    // tab_text_textview.setTextColor(getResources().getColor(R.color.indicator_tab_main_text_color));
    XmlPullParser xrp = getResources().getXml(tabTextColor);
    try {
        ColorStateList csl = ColorStateList.createFromXml(getResources(), xrp);

        if (tab_text_textview != null) {
            tab_text_textview.setTextColor(csl);
        }
    } catch (Exception e) {

    }
    tab_text_textview.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
    tab_text_textview.setTypeface(tabTypeface, tabTypefaceStyle);
    LinearLayout.LayoutParams lpText = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT);
    if (iconResId != 0) {
        // tab_text_textview.setCompoundDrawablesWithIntrinsicBounds(
        // iconResId, 0, 0, 0);
        // Drawable mDrawable = ((Activity) getContext()).getResources()
        // .getDrawable(iconResId);
        // mDrawable.setBounds(0, 0, mDrawable.getMinimumWidth(),
        // mDrawable.getMinimumHeight());
        int iPandding = (int) ((Activity) getContext()).getResources().getDimension(R.dimen.common_padding);
        ImageView icon = new ImageView(getContext());
        icon.setImageResource(iconResId);
        icon.setScaleType(ScaleType.CENTER_INSIDE);
        LinearLayout.LayoutParams lpImage = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                iIconHeight);

        switch (iIconLocation) {
        case 1:
            // tab_text_textview.setCompoundDrawables(mDrawable, null, null,
            // null);
            tabView.setOrientation(LinearLayout.HORIZONTAL);
            // tabView.setGravity(Gravity.CENTER_VERTICAL);

            tabView.addView(icon, lpImage);
            lpText.leftMargin = iPandding;
            tabView.addView(tab_text_textview, lpText);
            break;
        case 2:
            // tab_text_textview.setCompoundDrawables(null, mDrawable, null,
            // null);
            tabView.setOrientation(LinearLayout.VERTICAL);
            // tabView.setGravity(Gravity.CENTER_HORIZONTAL);
            tabView.addView(icon, lpImage);
            lpText.topMargin = iPandding;
            tabView.addView(tab_text_textview, lpText);
            break;
        case 3:
            // tab_text_textview.setCompoundDrawables(null, null, mDrawable,
            // null);
            tabView.setOrientation(LinearLayout.HORIZONTAL);
            // tabView.setGravity(Gravity.CENTER_VERTICAL);
            tabView.addView(tab_text_textview, lpText);
            lpImage.leftMargin = iPandding;
            tabView.addView(icon, lpImage);
            break;
        case 4:
            // tab_text_textview.setCompoundDrawables(null, null, null,
            // mDrawable);
            tabView.setOrientation(LinearLayout.VERTICAL);
            // tabView.setGravity(Gravity.CENTER_HORIZONTAL);
            tabView.addView(tab_text_textview, lpText);
            lpImage.topMargin = iPandding;
            tabView.addView(icon, lpImage);
            break;
        default:
            // tab_text_textview.setCompoundDrawables(mDrawable, null, null,
            // null);
            tabView.setOrientation(LinearLayout.HORIZONTAL);
            // tabView.setGravity(Gravity.CENTER_VERTICAL);
            tabView.addView(icon, lpImage);
            lpText.leftMargin = iPandding;
            tabView.addView(tab_text_textview, lpText);
            break;
        }

        // tab_text_textview
        // .setCompoundDrawablePadding((int) ((Activity) getContext())
        // .getResources()
        // .getDimension(R.dimen.common_padding));

    } else {
        tabView.addView(tab_text_textview, lpText);
    }

    tabView.setFocusable(true);
    tabView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            pager.setCurrentItem(position);
        }
    });

    // tab_text_textview.setPadding(tabPadding, 0, tabPadding, 0);
    tabsContainer.addView(tabView, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams);
}

From source file:com.wangbb.naruto.app.view.PagerSlidingTabStrip.java

private void addTab(final int position, CharSequence title, int iconResId, int iLayoutResId, int iTextId,
        int iIconLocation) {
    // final View tabView = ((Activity) getContext()).getLayoutInflater()
    // .inflate(iLayoutResId, null);
    // TextView tab_text_textview = (TextView)
    // tabView.findViewById(iTextId);
    // tab_text_textview.setText(title);
    LinearLayout tabView = new LinearLayout(getContext());
    tabView.setGravity(Gravity.CENTER);/*from   w  ww  .  j  a  v  a2 s  .c  o  m*/
    TextView tab_text_textview = new TextView(getContext());
    tab_text_textview.setId(position);
    tab_text_textview.setText(title);
    tab_text_textview.setGravity(Gravity.CENTER_VERTICAL);
    tab_text_textview.setSingleLine();
    // tab_text_textview.setTextColor(tabTextColor);
    // tab_text_textview.setTextColor(getResources().getColor(R.color.indicator_tab_main_text_color));
    //      XmlPullParser xrp = getResources().getXml(tabTextColor);
    //      try {
    //         ColorStateList csl = ColorStateList.createFromXml(getResources(),
    //               xrp);

    //         if (tab_text_textview != null) {
    tab_text_textview.setTextColor(tabTextColor);
    //         }
    //      } catch (Exception e) {
    //
    //      }
    tab_text_textview.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
    tab_text_textview.setTypeface(tabTypeface, tabTypefaceStyle);
    LinearLayout.LayoutParams lpText = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT);
    if (iconResId != 0) {
        // tab_text_textview.setCompoundDrawablesWithIntrinsicBounds(
        // iconResId, 0, 0, 0);
        // Drawable mDrawable = ((Activity) getContext()).getResources()
        // .getDrawable(iconResId);
        // mDrawable.setBounds(0, 0, mDrawable.getMinimumWidth(),
        // mDrawable.getMinimumHeight());
        int iPandding = (int) ((Activity) getContext()).getResources().getDimension(R.dimen.common_padding);
        ImageView icon = new ImageView(getContext());
        icon.setImageResource(iconResId);
        icon.setScaleType(ScaleType.CENTER_INSIDE);
        LinearLayout.LayoutParams lpImage = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                iIconHeight);

        switch (iIconLocation) {
        case 1:
            // tab_text_textview.setCompoundDrawables(mDrawable, null, null,
            // null);
            tabView.setOrientation(LinearLayout.HORIZONTAL);
            // tabView.setGravity(Gravity.CENTER_VERTICAL);

            tabView.addView(icon, lpImage);
            lpText.leftMargin = iPandding;
            tabView.addView(tab_text_textview, lpText);
            break;
        case 2:
            // tab_text_textview.setCompoundDrawables(null, mDrawable, null,
            // null);
            tabView.setOrientation(LinearLayout.VERTICAL);
            // tabView.setGravity(Gravity.CENTER_HORIZONTAL);
            tabView.addView(icon, lpImage);
            lpText.topMargin = iPandding;
            tabView.addView(tab_text_textview, lpText);
            break;
        case 3:
            // tab_text_textview.setCompoundDrawables(null, null, mDrawable,
            // null);
            tabView.setOrientation(LinearLayout.HORIZONTAL);
            // tabView.setGravity(Gravity.CENTER_VERTICAL);
            tabView.addView(tab_text_textview, lpText);
            lpImage.leftMargin = iPandding;
            tabView.addView(icon, lpImage);
            break;
        case 4:
            // tab_text_textview.setCompoundDrawables(null, null, null,
            // mDrawable);
            tabView.setOrientation(LinearLayout.VERTICAL);
            // tabView.setGravity(Gravity.CENTER_HORIZONTAL);
            tabView.addView(tab_text_textview, lpText);
            lpImage.topMargin = iPandding;
            tabView.addView(icon, lpImage);
            break;
        default:
            // tab_text_textview.setCompoundDrawables(mDrawable, null, null,
            // null);
            tabView.setOrientation(LinearLayout.HORIZONTAL);
            // tabView.setGravity(Gravity.CENTER_VERTICAL);
            tabView.addView(icon, lpImage);
            lpText.leftMargin = iPandding;
            tabView.addView(tab_text_textview, lpText);
            break;
        }

        // tab_text_textview
        // .setCompoundDrawablePadding((int) ((Activity) getContext())
        // .getResources()
        // .getDimension(R.dimen.common_padding));

    } else {
        tabView.addView(tab_text_textview, lpText);
    }

    tabView.setFocusable(true);
    tabView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            pager.setCurrentItem(position);
        }
    });

    // tab_text_textview.setPadding(tabPadding, 0, tabPadding, 0);
    tabsContainer.addView(tabView, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams);
}

From source file:com.mk4droid.IMC_Activities.FActivity_TabHost.java

private LinearLayout make_Active_Tab(String text, Drawable dr) {

    LinearLayout ll = new LinearLayout(this);
    ll.setPadding(0, 0, 2, 1);/*from   www. j  a  v a2  s. co  m*/
    ll.setBackgroundColor(Color.GRAY);

    ll.setTag("ll");
    ll.setOrientation(LinearLayout.VERTICAL);
    ll.setLayoutParams(
            new LinearLayout.LayoutParams(0, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT, 1));

    //------ Text 
    TextView tv = new TextView(this);
    tv.setBackgroundColor(Color.TRANSPARENT);
    tv.setTag("tv");
    ll.addView(tv);

    // ------ hbar
    View hbar = new View(this);
    hbar.setTag("hbar");
    hbar.setLayoutParams(
            new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.FILL_PARENT, 10));

    ll.addView(hbar);

    ////////////////////////////////////////
    return ActivateColorize(ll, text, dr);
}

From source file:fr.cph.chicago.core.adapter.NearbyAdapter.java

private View handleBuses(final int position, @NonNull final ViewGroup parent) {
    final LayoutInflater vi = (LayoutInflater) parent.getContext()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final View convertView = vi.inflate(R.layout.list_nearby, parent, false);

    // Bus/*from   www . j  a v  a2s . co  m*/
    final int index = position - stations.size();
    final BusStop busStop = busStops.get(index);

    final ImageView imageView = (ImageView) convertView.findViewById(R.id.icon);
    imageView.setImageDrawable(
            ContextCompat.getDrawable(parent.getContext(), R.drawable.ic_directions_bus_white_24dp));

    final TextView routeView = (TextView) convertView.findViewById(R.id.station_name);
    routeView.setText(busStop.getName());

    final LinearLayout resultLayout = (LinearLayout) convertView.findViewById(R.id.nearby_results);

    final Map<String, List<BusArrival>> arrivalsForStop = busArrivals.get(busStop.getId(), new HashMap<>());

    Stream.of(arrivalsForStop.entrySet()).forEach(entry -> {
        final LinearLayout.LayoutParams leftParam = new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        final RelativeLayout insideLayout = new RelativeLayout(context);
        insideLayout.setLayoutParams(leftParam);
        insideLayout.setPadding(line1PaddingColor * 2, stopsPaddingTop, 0, 0);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            insideLayout.setBackground(ContextCompat.getDrawable(parent.getContext(), R.drawable.any_selector));
        }

        final RelativeLayout lineIndication = LayoutUtil.createColoredRoundForFavorites(context, TrainLine.NA);
        int lineId = Util.generateViewId();
        lineIndication.setId(lineId);

        final RelativeLayout.LayoutParams stopParam = new RelativeLayout.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        stopParam.addRule(RelativeLayout.RIGHT_OF, lineId);
        stopParam.setMargins(Util.convertDpToPixel(context, 10), 0, 0, 0);

        final LinearLayout stopLayout = new LinearLayout(context);
        stopLayout.setOrientation(LinearLayout.VERTICAL);
        stopLayout.setLayoutParams(stopParam);
        int stopId = Util.generateViewId();
        stopLayout.setId(stopId);

        final RelativeLayout.LayoutParams boundParam = new RelativeLayout.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        boundParam.addRule(RelativeLayout.RIGHT_OF, stopId);

        final LinearLayout boundLayout = new LinearLayout(context);
        boundLayout.setOrientation(LinearLayout.HORIZONTAL);

        final String direction = entry.getKey();
        final List<BusArrival> busArrivals = entry.getValue();
        final String routeId = busArrivals.get(0).getRouteId();

        final TextView bound = new TextView(context);
        final String routeIdText = routeId + " (" + direction + "): ";
        bound.setText(routeIdText);
        bound.setTextColor(ContextCompat.getColor(context, R.color.grey_5));
        boundLayout.addView(bound);

        Stream.of(busArrivals).forEach(busArrival -> {
            final TextView timeView = new TextView(context);
            final String timeLeftDueDelay = busArrival.getTimeLeftDueDelay() + " ";
            timeView.setText(timeLeftDueDelay);
            timeView.setTextColor(ContextCompat.getColor(context, R.color.grey));
            timeView.setLines(1);
            timeView.setEllipsize(TruncateAt.END);
            boundLayout.addView(timeView);
        });

        stopLayout.addView(boundLayout);

        insideLayout.addView(lineIndication);
        insideLayout.addView(stopLayout);
        resultLayout.addView(insideLayout);
    });

    convertView.setOnClickListener(new NearbyOnClickListener(googleMap, markers, busStop.getId(),
            busStop.getPosition().getLatitude(), busStop.getPosition().getLongitude()));
    return convertView;
}

From source file:it.ielettronica.TVS.MyListAdapterExt.java

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    //If there's no recycled view, inflate one and tag each of the views
    //you'll want to modify later
    //Log.d("Inside", "GetView");

    plv = null;//  w ww  .  j a  va2 s .  co m
    if (convertView == null) {

        convertView = mInflater.inflate(R.layout.row_site_remote, parent, false);
        plv = new PlaylistValues();

        plv.nameTxt = (TextView) convertView.findViewById(R.id.nameTxt);
        plv.aboutTxt = (TextView) convertView.findViewById(R.id.aboutTxt);
        plv.iconImg = (ImageView) convertView.findViewById(R.id.iconImg);
        plv.btnPlayLocal = (Button) convertView.findViewById(R.id.btnPlayLocal);
        plv.indicator = (ProgressBar) convertView.findViewById(R.id.progress);
        plv.btnAddLocal = (Button) convertView.findViewById(R.id.btnAddLocal);
        plv.imageState = (ImageView) convertView.findViewById(R.id.imgState);
        plv.btnEditDel = (Button) convertView.findViewById(R.id.btnEditDel);
        //This assumes layout/row_left.xml includes a TextView with an id of "textview"
        convertView.setTag(plv);
    } else {
        plv = (PlaylistValues) convertView.getTag();
    }

    //Initially we want the progress indicator visible, and the image invisible
    plv.indicator.setVisibility(View.VISIBLE);
    plv.iconImg.setVisibility(View.INVISIBLE);

    if (MainActivity.isAmministrator()) {
        plv.btnEditDel.setVisibility(View.VISIBLE);
    } else {
        plv.btnEditDel.setVisibility(View.INVISIBLE);
    }

    //Retrieve the tagged view, get the item for that position, and
    //update the text

    ImageLoadingListener listener = new ImageLoadingListener() {

        @Override
        public void onLoadingStarted(String arg0, View arg1) {
            // TODO Auto-generated method stub
            plv.indicator.setVisibility(View.INVISIBLE);
            plv.iconImg.setVisibility(View.VISIBLE);

        }

        @Override
        public void onLoadingCancelled(String arg0, View arg1) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onLoadingComplete(String arg0, View arg1, Bitmap arg2) {
            //plv.indicator.setVisibility(View.INVISIBLE);
            //plv.iconImg.setVisibility(View.VISIBLE);
        }

        @Override
        public void onLoadingFailed(String arg0, View arg1, FailReason arg2) {
            // TODO Auto-generated method stub

        }

    };

    stk = mItems.get(position);
    plv.nameTxt.setText(stk.getName());
    plv.aboutTxt.setText(stk.getAbout());

    String uri = "@drawable/myresource"; // where myresource.png is the file
    // extension removed from the String

    if (MainActivity.isAmministrator() == Boolean.TRUE) {
        Drawable res;
        if (stk.getAccepted() == 1) {
            res = ContextCompat.getDrawable(MainActivity.getAppContext(), R.drawable.good);
        } else {
            res = ContextCompat.getDrawable(MainActivity.getAppContext(), R.drawable.warning);
        }
        plv.imageState.setImageDrawable(res);
    }

    imageLoader.displayImage(stk.getImgUrl(), plv.iconImg, options, listener);

    plv.btnEditDel.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            final StackSite stkloc = mItems.get(position);
            MainActivity.posRemoteListBeforeExecuted = sitesMusic.getFirstVisiblePosition();
            Intent intent = new Intent(MainActivity.getAppContext(), ModChannel.class);

            intent.putExtra("TitleChannel", stkloc.getName());
            intent.putExtra("DescrChannel", stkloc.getAbout());
            intent.putExtra("IconChannel", stkloc.getImgUrl());
            intent.putExtra("isAccepted", stkloc.getAccepted());
            intent.putExtra("NameGroup", GroupVSeletced.getGroupName());
            intent.putExtra("LevelGroup", GroupVSeletced.getGroupLevel());
            intent.putExtra("TypeGroup", GroupVSeletced.getGroupType());

            intent.putExtra("GroupLevel", GroupVSeletced.getGroupLevel());
            tabFromDB.fa.startActivity(intent);

        }
    });

    plv.btnPlayLocal.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            //                final Intent intent = new Intent(v.getContext(), MediaPlayerDemo_Video.class);
            final StackSite stkloc = mItems.get(position);
            MainActivity.posRemoteListBeforeExecuted = sitesMusic.getFirstVisiblePosition();

            GroupType = GroupVSeletced.getGroupType();

            RemoteCommunications rm = new RemoteCommunications();
            List<StackLink> Links = new ArrayList<StackLink>();
            rm.getLinks(Links, stkloc.getName(), new GetLinkCallback() {
                @Override
                public void done(List<StackLink> returnedLinks) {
                    List<StackLink> Links = returnedLinks;
                    if (Links.size() == 1) {
                        MainActivity.posLocalListBeforeExecuted = tabFromDB.sitesMusic
                                .getFirstVisiblePosition();
                        if (MainActivity.isAmministrator()) {

                            Intent intent = new Intent(MainActivity.getAppContext(), LinksLists.class);
                            intent.putExtra("VideoStreamName", stkloc.getName());
                            intent.putExtra("GroupType", GroupType);

                            tabFromDB.fa.startActivity(intent);

                        } else {
                            String linkVal = Links.get(0).getLinkValue();
                            //Uri myUri = Uri.parse(linkVal);

                            if (GroupType == 0) {

                                Intent mpdIntent = new Intent(tabLocal.Fa.getContext(), PlayerActivity.class)
                                        .setData(Uri.parse(linkVal))
                                        .putExtra(PlayerActivity.CONTENT_ID_EXTRA, "")
                                        .putExtra(PlayerActivity.CONTENT_TYPE_EXTRA, PlayerActivity.TYPE_HLS)
                                        .putExtra(PlayerActivity.PROVIDER_EXTRA, "");
                                tabFromDB.fa.getContext().startActivity(mpdIntent);

                            } else if (GroupType == 1) {

                                //                                    Intent intent2 = new Intent(tabLocal.Fa.getContext(), MediaPlayerDemo_VideoView.class);
                                //                                    intent2.putExtra("pathValue", linkVal);
                                //                                    tabFromDB.fa.getContext().startActivity(intent2);

                            } else {

                                //                                    intent.putExtra("media", 5);
                                //                                    intent.putExtra("pathValue", linkVal);
                                //
                                //                                    try {
                                //                                        tabFromDB.fa.startActivity(intent);
                                //                                    } catch (Exception ex) {
                                //                                        Toast.makeText(cloc, ex.toString(),
                                //                                                Toast.LENGTH_SHORT).show();
                                //                                    }

                            }

                            Toast.makeText(cloc, "Play: " + stkloc.getName(), Toast.LENGTH_SHORT).show();

                        }

                    } else if (Links.size() == 0) {
                        Toast.makeText(cloc,
                                "the channel:  '" + stkloc.getName() + "' doesn't have any link associated",
                                Toast.LENGTH_SHORT).show();
                    } else {

                        Intent intent = new Intent(MainActivity.getAppContext(), LinksLists.class);
                        intent.putExtra("VideoStreamName", stkloc.getName());
                        tabFromDB.fa.startActivity(intent);

                    }
                }
            });

        }
    });

    plv.btnAddLocal.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            stkloc = mItems.get(position);

            RemoteCommunications rm = new RemoteCommunications();
            List<StackLink> Links = new ArrayList<StackLink>();
            rm.getLinks(Links, stkloc.getName(), new GetLinkCallback() {
                @Override
                public void done(List<StackLink> returnedLinks) {

                    AlertDialog.Builder alertDialog;
                    try {
                        alertDialog = new AlertDialog.Builder(tabFromDB.fa.getContext());
                    } catch (Exception ex) {
                        alertDialog = new AlertDialog.Builder(MainActivity.getAppContext());
                    }

                    retLinks = returnedLinks;
                    LinearLayout layout = new LinearLayout(MainActivity.getAppContext());
                    layout.setOrientation(LinearLayout.VERTICAL);

                    if (returnedLinks.size() > 1) {

                        LinearLayout rlayoutLink = new LinearLayout(MainActivity.getAppContext());
                        rlayoutLink.setOrientation(LinearLayout.HORIZONTAL);
                        final TextView textView = new TextView(MainActivity.getAppContext());
                        textView.setText("Links:  ");
                        textView.setGravity(Gravity.RIGHT);
                        textView.setLayoutParams(
                                new FrameLayout.LayoutParams(400, LinearLayout.LayoutParams.WRAP_CONTENT));
                        rlayoutLink.addView(textView);
                        listLinks = new Spinner(MainActivity.getAppContext());

                        List<String> retLinksString = new ArrayList<String>();
                        for (int i = 0; i < returnedLinks.size(); i++) {
                            retLinksString.add(returnedLinks.get(i).getLinkTxt());
                        }

                        listLinks.setAdapter(new MyCustomAdapter(MainActivity.getAppContext(),
                                R.layout.rowspinnertake, retLinksString, returnedLinks));

                        //ArrayAdapter<String> adapter = new ArrayAdapter<String>(MainActivity.getAppContext(), android.R.layout.simple_spinner_item, retLinksString);
                        //adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                        //listLinks.setAdapter(adapter);

                        listLinks.setLayoutParams(
                                new FrameLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                                        LinearLayout.LayoutParams.WRAP_CONTENT));

                        rlayoutLink.addView(listLinks);
                        layout.addView(rlayoutLink);
                    }

                    final Button btnAddToTheEnd = new Button(MainActivity.getAppContext());
                    btnAddToTheEnd.setText("Add");

                    btnAddToTheEnd.setOnClickListener(new View.OnClickListener() {
                        public void onClick(View v) {

                            StackSite stkloc = mItems.get(position);

                            if (listLinks != null) {
                                posSpinnerLink = listLinks.getSelectedItemPosition();
                            } else {
                                posSpinnerLink = 0;
                            }

                            if (retLinks.size() == 0) {
                                Toast.makeText(cloc,
                                        "the channel:  '" + stkloc.getName()
                                                + "' doesn't have any link associated",
                                        Toast.LENGTH_SHORT).show();
                            } else {

                                String url;

                                if (retLinks.size() == 1) {

                                    url = retLinks.get(0).getLinkValue();

                                } else {
                                    url = retLinks.get(posSpinnerLink).getLinkValue();
                                }

                                stkloc.setLink(url);
                                stkloc.setTypeStream(GroupVSeletced.getGroupType());
                                stkloc.setStaticName(stkloc.getName());
                                String nameStation = stkloc.getName();
                                stkloc.setOrigin(0);
                                boolean isAdded = dbHandler.addSite(stkloc);
                                if (isAdded) {
                                    Toast.makeText(MainActivity.getAppContext(),
                                            nameStation + " is added in Local Playlist", Toast.LENGTH_SHORT)
                                            .show();
                                }
                                List<StackSite> itemsLocal;
                                itemsLocal = dbHandler.getStackSites();
                                if (itemsLocal.size() == 0) {
                                    tabLocal.editEmptyLocalList.setVisibility(View.VISIBLE);
                                } else {
                                    tabLocal.editEmptyLocalList.setVisibility(View.INVISIBLE);
                                }

                                tabLocal.sitesLocal.setCheeseList(itemsLocal);
                                tabLocal.sitesLocal.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
                                StableArrayAdapter adapterLocal = new StableArrayAdapter(
                                        tabLocal.Fa.getContext(), R.layout.row_site_local, itemsLocal);
                                tabLocal.sitesLocal.setAdapter(adapterLocal);

                                OptionDialog.dismiss();

                            }

                        }
                    });
                    btnAddToTheEnd.setLayoutParams(
                            new FrameLayout.LayoutParams(400, LinearLayout.LayoutParams.WRAP_CONTENT));
                    layout.addView(btnAddToTheEnd);

                    final Button btnAddAfter = new Button(MainActivity.getAppContext());
                    final Spinner listChannelAlreadyAdded = new Spinner(MainActivity.getAppContext());
                    List<String> ListNameChannel;
                    ListNameChannel = dbHandler.getNamesFromStackSites();
                    ArrayAdapter<String> adapter2 = new ArrayAdapter<String>(MainActivity.getAppContext(),
                            android.R.layout.simple_spinner_item, ListNameChannel);
                    adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                    listChannelAlreadyAdded.setAdapter(adapter2);
                    posSpinner = listChannelAlreadyAdded.getSelectedItemPosition();

                    if (posSpinner != -1) {
                        LinearLayout rlayout = new LinearLayout(MainActivity.getAppContext());
                        rlayout.setOrientation(LinearLayout.HORIZONTAL);

                        btnAddAfter.setText("Add Before");
                        btnAddAfter.setOnClickListener(new View.OnClickListener() {
                            public void onClick(View v) {

                                if (listLinks != null) {
                                    posSpinnerLink = listLinks.getSelectedItemPosition();
                                } else {
                                    posSpinnerLink = 0;
                                }

                                StackSite stkloc = mItems.get(position);

                                if (retLinks.size() == 0) {
                                    Toast.makeText(cloc,
                                            "the channel:  '" + stkloc.getName()
                                                    + "' doesn't have any link associated",
                                            Toast.LENGTH_SHORT).show();
                                } else {

                                    String url;

                                    if (retLinks.size() == 1) {

                                        url = retLinks.get(0).getLinkValue();

                                    } else {
                                        url = retLinks.get(posSpinnerLink).getLinkValue();
                                    }

                                    stkloc.setLink(url);
                                    stkloc.setOrigin(0);
                                    stkloc.setTypeStream(GroupVSeletced.getGroupType());
                                    String nameStation = stkloc.getName();
                                    posSpinner = listChannelAlreadyAdded.getSelectedItemPosition();

                                    boolean isAdded = dbHandler.addSiteBefore(stkloc, posSpinner);
                                    if (isAdded) {
                                        Toast.makeText(MainActivity.getAppContext(),
                                                nameStation + " is added in Local Playlist", Toast.LENGTH_SHORT)
                                                .show();
                                    }
                                    List<StackSite> itemsLocal;
                                    itemsLocal = dbHandler.getStackSites();
                                    tabLocal.sitesLocal.setCheeseList(itemsLocal);
                                    tabLocal.sitesLocal.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
                                    StableArrayAdapter adapterLocal = new StableArrayAdapter(
                                            tabLocal.Fa.getContext(), R.layout.row_site_local, itemsLocal);
                                    tabLocal.sitesLocal.setAdapter(adapterLocal);

                                    OptionDialog.dismiss();

                                }

                            }
                        });

                        btnAddAfter.setLayoutParams(
                                new FrameLayout.LayoutParams(400, LinearLayout.LayoutParams.WRAP_CONTENT));
                        rlayout.addView(btnAddAfter);
                        listChannelAlreadyAdded.setLayoutParams(
                                new FrameLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                                        LinearLayout.LayoutParams.WRAP_CONTENT));
                        rlayout.addView(listChannelAlreadyAdded);
                        layout.addView(rlayout);
                    }

                    final Button btnCancel = new Button(MainActivity.getAppContext());
                    btnCancel.setText("Cancel");
                    btnCancel.setLayoutParams(
                            new FrameLayout.LayoutParams(400, LinearLayout.LayoutParams.WRAP_CONTENT));

                    btnCancel.setOnClickListener(new View.OnClickListener() {
                        public void onClick(View v) {
                            OptionDialog.dismiss();
                        }
                    });

                    layout.addView(btnCancel);
                    alertDialog.setView(layout); // uncomment this line
                    alertDialog.setTitle("Take the Channel");
                    OptionDialog = alertDialog.create();
                    OptionDialog.show();
                }

            });

        }

    });

    return convertView;
}

From source file:com.mk4droid.IMC_Activities.FActivity_TabHost.java

private LinearLayout make_Inactive_Tab(String text, Drawable dr) {

    LinearLayout ll = new LinearLayout(this);

    ll.setPadding(0, 0, 2, 1);/*from  www . j a  v a 2s  .  c om*/

    ll.setBackgroundColor(Color.GRAY);

    ll.setTag("ll");
    ll.setOrientation(LinearLayout.VERTICAL);
    ll.setLayoutParams(
            new LinearLayout.LayoutParams(0, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT, 1));

    //------ Text 
    TextView tv = new TextView(this);
    tv.setBackgroundColor(Color.TRANSPARENT);
    tv.setTag("tv");
    ll.addView(tv);

    // ------ hbar
    View hbar = new View(this);
    hbar.setTag("hbar");
    hbar.setLayoutParams(
            new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.FILL_PARENT, 10));

    ll.addView(hbar);

    /////////////////////////////////////
    return InActivateColorize(ll, text, dr);
}

From source file:com.grarak.kerneladiutor.fragments.other.SettingsFragment.java

private void editPasswordDialog(final String oldPass) {
    mOldPassword = oldPass;//from ww  w.jav  a  2  s  .  c om

    LinearLayout linearLayout = new LinearLayout(getActivity());
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    linearLayout.setGravity(Gravity.CENTER);
    int padding = Math.round(getResources().getDimension(R.dimen.dialog_padding));
    linearLayout.setPadding(padding, padding, padding, padding);

    final AppCompatEditText oldPassword = new AppCompatEditText(getActivity());
    if (!oldPass.isEmpty()) {
        oldPassword.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
        oldPassword.setHint(getString(R.string.old_password));
        linearLayout.addView(oldPassword);
    }

    final AppCompatEditText newPassword = new AppCompatEditText(getActivity());
    newPassword.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    newPassword.setHint(getString(R.string.new_password));
    linearLayout.addView(newPassword);

    final AppCompatEditText confirmNewPassword = new AppCompatEditText(getActivity());
    confirmNewPassword.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    confirmNewPassword.setHint(getString(R.string.confirm_new_password));
    linearLayout.addView(confirmNewPassword);

    new Dialog(getActivity()).setView(linearLayout)
            .setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                }
            }).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    if (!oldPass.isEmpty()
                            && !oldPassword.getText().toString().equals(Utils.decodeString(oldPass))) {
                        Utils.toast(getString(R.string.old_password_wrong), getActivity());
                        return;
                    }

                    if (newPassword.getText().toString().isEmpty()) {
                        Utils.toast(getString(R.string.password_empty), getActivity());
                        return;
                    }

                    if (!newPassword.getText().toString().equals(confirmNewPassword.getText().toString())) {
                        Utils.toast(getString(R.string.password_not_match), getActivity());
                        return;
                    }

                    if (newPassword.getText().toString().length() > 32) {
                        Utils.toast(getString(R.string.password_too_long), getActivity());
                        return;
                    }

                    Prefs.saveString("password", Utils.encodeString(newPassword.getText().toString()),
                            getActivity());
                    if (mFingerprint != null) {
                        mFingerprint.setEnabled(true);
                    }
                }
            }).setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialogInterface) {
                    mOldPassword = null;
                }
            }).show();
}

From source file:com.citrus.sample.WalletPaymentFragment.java

private void showPrompt(final Utils.PaymentType paymentType) {
    final AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
    String message = null;/*from  w  w w .j  a  v  a 2 s  . c om*/
    String positiveButtonText = null;

    switch (paymentType) {
    case LOAD_MONEY:
    case AUTO_LOAD_MONEY:
        message = "Please enter the amount to load.";
        positiveButtonText = "Load Money";
        break;
    case CITRUS_CASH:
    case NEW_CITRUS_CASH:
        message = "Please enter the transaction amount.";
        positiveButtonText = "Pay";
        break;
    case PG_PAYMENT:
    case NEW_PG_PAYMENT:
    case WALLET_PG_PAYMENT:
        message = "Please enter the transaction amount.";
        positiveButtonText = "Make Payment";
        break;
    }

    LinearLayout linearLayout = new LinearLayout(getActivity());
    linearLayout.setOrientation(LinearLayout.VERTICAL);

    alert.setTitle("Transaction Amount?");
    alert.setMessage(message);
    // Set an EditText view to get user input
    final EditText input = new EditText(getActivity());
    input.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
    alert.setView(input);
    alert.setPositiveButton(positiveButtonText, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int whichButton) {
            String value = input.getText().toString();

            mListener.onPaymentTypeSelected(paymentType, new Amount(value));

            input.clearFocus();
            // Hide the keyboard.
            InputMethodManager imm = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(input.getWindowToken(), 0);
        }
    });

    alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            dialog.cancel();
        }
    });

    input.requestFocus();
    alert.show();
}

From source file:com.cmput301w15t15.travelclaimsapp.activitys.EditClaimActivity.java

/**
 * Function that is called when you press the add tag
 * //ww w. j  av a  2  s.c  o m
 * Creates a alert dialog that gives the user the option 
 * of adding a previously added tag or entering a new tag name
 * 
 * @param view
 */
public void addTagButton(View view) {
    final EditText enterTag = new EditText(this);
    final Spinner tagSpinner = new Spinner(this);
    //Linear layout that holds enterTag and tagSpinner views
    LinearLayout ll = new LinearLayout(this);
    ll.setOrientation(LinearLayout.VERTICAL);
    tagSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View arg1, int position, long id) {
            enterTag.setText(parent.getItemAtPosition(position).toString());
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub      
        }
    });

    enterTag.setHint("Enter tag");
    AlertDialog.Builder alert = new AlertDialog.Builder(this);

    //get all the tags currently added to claims in application claimlist
    ArrayList<Tag> tags = ClaimListController.getTagList();
    String t[] = new String[tags.size()];
    for (int i = 0; i < tags.size(); i++) {
        t[i] = tags.get(i).getName();
    }
    //create a arrayadaptor for displaying the tagSpinner view, and set it
    ArrayAdapter<String> tagA = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, t);
    tagSpinner.setAdapter(tagA);
    //add views to linear layout and set the Linear layout view as the alert dialog view 
    ll.addView(tagSpinner);
    ll.addView(enterTag);
    alert.setView(ll);

    alert.setPositiveButton("Add", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            Tag tag = new Tag(enterTag.getText().toString());
            if (theClaim.getTagList().getTag(enterTag.getText().toString()) != null) {
                return;
            }
            ClaimListController.addTag(theClaim, tag);
            tagAdaptor.notifyDataSetChanged();
        }
    });
    alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            dialog.cancel();
        }
    });

    alert.show();
}