Example usage for android.widget LinearLayout removeAllViews

List of usage examples for android.widget LinearLayout removeAllViews

Introduction

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

Prototype

public void removeAllViews() 

Source Link

Document

Call this method to remove all child views from the ViewGroup.

Usage

From source file:anastasoft.rallyvision.activity.MenuPrincipal.java

public void makeConnectOff() {
    LinearLayout mConnectLayout = (LinearLayout) findViewById(R.id.ConnecLayout);
    mConnectLayout.removeAllViews();

    // Create new LayoutInflater - this has to be done this way, as you can't directly inflate an XML without creating an inflater object first
    LayoutInflater inflater = getLayoutInflater();
    mConnectLayout.addView(inflater.inflate(R.layout.connect_button_green_escuro, null));
    mConnectLayout.findViewById(R.id.executar).setOnLongClickListener(new OnLongClickListener() {
        @Override//w w  w  .  j a  v a  2 s .c  o m
        public boolean onLongClick(View v) {
            startProcedure(v);

            return true;
        }
    });

}

From source file:anastasoft.rallyvision.activity.MenuPrincipal.java

public void makeConnectOn() {
    LinearLayout mConnectLayout = (LinearLayout) findViewById(R.id.ConnecLayout);

    mConnectLayout.removeAllViews();

    // Create new LayoutInflater - this has to be done this way, as you can't directly inflate an XML without creating an inflater object first
    LayoutInflater inflater = getLayoutInflater();
    mConnectLayout.addView(inflater.inflate(R.layout.connect_button_green, null));
    mConnectLayout.findViewById(R.id.executar).setOnLongClickListener(new OnLongClickListener() {
        @Override/* ww  w.  j  a  va  2 s  .co  m*/
        public boolean onLongClick(View v) {
            stopCom(v);
            return true;
        }
    });

}

From source file:com.amsterdam.marktbureau.makkelijkemarkt.DagvergunningFragmentKoopman.java

/**
 * Populate the koopman fragment item details item when the loader has finished
 * @param loader the cursor loader/*from   w  w w. java2s. c  o m*/
 * @param data data object containing one or more koopman rows with joined sollicitatie data
 */
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    if (data != null && data.moveToFirst()) {
        boolean validSollicitatie = false;

        // get the markt id from the sharedprefs
        SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getContext());
        int marktId = settings.getInt(getContext().getString(R.string.sharedpreferences_key_markt_id), 0);

        // make the koopman details visible
        mKoopmanDetail.setVisibility(View.VISIBLE);

        // check koopman status
        String koopmanStatus = data.getString(data.getColumnIndex("koopman_status"));
        mMeldingVerwijderd = koopmanStatus.equals(getString(R.string.koopman_status_verwijderd));

        // koopman photo
        Glide.with(getContext())
                .load(data.getString(data.getColumnIndex(MakkelijkeMarktProvider.Koopman.COL_FOTO_URL)))
                .error(R.drawable.no_koopman_image).into(mKoopmanFotoImage);

        // koopman naam
        String naam = data.getString(data.getColumnIndex(MakkelijkeMarktProvider.Koopman.COL_VOORLETTERS)) + " "
                + data.getString(data.getColumnIndex(MakkelijkeMarktProvider.Koopman.COL_ACHTERNAAM));
        mKoopmanVoorlettersAchternaamText.setText(naam);

        // koopman erkenningsnummer
        mErkenningsnummer = data
                .getString(data.getColumnIndex(MakkelijkeMarktProvider.Koopman.COL_ERKENNINGSNUMMER));
        mErkenningsnummerText.setText(mErkenningsnummer);

        // koopman sollicitaties
        View view = getView();
        if (view != null) {
            LayoutInflater layoutInflater = (LayoutInflater) getActivity()
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            LinearLayout placeholderLayout = (LinearLayout) view.findViewById(R.id.sollicitaties_placeholder);
            placeholderLayout.removeAllViews();

            // get vaste producten for selected markt, and add multiple markt sollicitatie views to the koopman items
            while (!data.isAfterLast()) {

                // get vaste producten for selected markt
                if (marktId > 0 && marktId == data
                        .getInt(data.getColumnIndex(MakkelijkeMarktProvider.Sollicitatie.COL_MARKT_ID))) {
                    String[] productParams = getResources().getStringArray(R.array.array_product_param);
                    for (String product : productParams) {
                        mProducten.put(product, data.getInt(data.getColumnIndex(product)));
                    }
                }

                // inflate sollicitatie layout and populate its view items
                View childLayout = layoutInflater.inflate(R.layout.dagvergunning_koopman_item_sollicitatie,
                        null);

                // highlight the sollicitatie for the current markt
                if (data.getCount() > 1 && marktId > 0 && marktId == data
                        .getInt(data.getColumnIndex(MakkelijkeMarktProvider.Sollicitatie.COL_MARKT_ID))) {
                    childLayout.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.primary));
                }

                // markt afkorting
                String marktAfkorting = data
                        .getString(data.getColumnIndex(MakkelijkeMarktProvider.Markt.COL_AFKORTING));
                TextView marktAfkortingText = (TextView) childLayout
                        .findViewById(R.id.sollicitatie_markt_afkorting);
                marktAfkortingText.setText(marktAfkorting);

                // koopman sollicitatienummer
                String sollicitatienummer = data.getString(
                        data.getColumnIndex(MakkelijkeMarktProvider.Sollicitatie.COL_SOLLICITATIE_NUMMER));
                TextView sollicitatienummerText = (TextView) childLayout
                        .findViewById(R.id.sollicitatie_sollicitatie_nummer);
                sollicitatienummerText.setText(sollicitatienummer);

                // koopman sollicitatie status
                String sollicitatieStatus = data.getString(data.getColumnIndex("sollicitatie_status"));
                TextView sollicitatieStatusText = (TextView) childLayout.findViewById(R.id.sollicitatie_status);
                sollicitatieStatusText.setText(sollicitatieStatus);
                if (sollicitatieStatus != null && !sollicitatieStatus.equals("?")
                        && !sollicitatieStatus.equals("")) {
                    sollicitatieStatusText
                            .setTextColor(ContextCompat.getColor(getContext(), android.R.color.white));
                    sollicitatieStatusText.setBackgroundColor(ContextCompat.getColor(getContext(),
                            Utility.getSollicitatieStatusColor(getContext(), sollicitatieStatus)));

                    // check if koopman has at least one valid sollicitatie on selected markt
                    if (marktId == data
                            .getInt(data.getColumnIndex(MakkelijkeMarktProvider.Sollicitatie.COL_MARKT_ID))) {
                        validSollicitatie = true;
                    }
                }

                // add view and move cursor to next
                placeholderLayout.addView(childLayout, data.getPosition());
                data.moveToNext();
            }
        }

        // check valid sollicitatie
        mMeldingNoValidSollicitatie = !validSollicitatie;

        // get the date of today for the dag param
        SimpleDateFormat sdf = new SimpleDateFormat(getString(R.string.date_format_dag));
        String dag = sdf.format(new Date());

        // check multiple dagvergunningen
        Cursor dagvergunningen = getContext().getContentResolver().query(
                MakkelijkeMarktProvider.mUriDagvergunningJoined, null,
                "dagvergunning_doorgehaald != '1' AND " + MakkelijkeMarktProvider.mTableDagvergunning + "."
                        + MakkelijkeMarktProvider.Dagvergunning.COL_MARKT_ID + " = ? AND "
                        + MakkelijkeMarktProvider.Dagvergunning.COL_DAG + " = ? AND "
                        + MakkelijkeMarktProvider.Dagvergunning.COL_ERKENNINGSNUMMER_INVOER_WAARDE + " = ? ",
                new String[] { String.valueOf(marktId), dag, mErkenningsnummer, }, null);
        mMeldingMultipleDagvergunningen = (dagvergunningen != null && dagvergunningen.moveToFirst())
                && (dagvergunningen.getCount() > 1 || mDagvergunningId == -1);
        if (dagvergunningen != null) {
            dagvergunningen.close();
        }

        // callback to dagvergunning activity to updaten the meldingen view
        ((Callback) getActivity()).onMeldingenUpdated();
    }
}

From source file:com.github.howeyc.slideshow.activities.SettingsActivity.java

@Override
protected void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);
    Toolbar bar;// w  ww . j a v  a 2 s.c om

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        LinearLayout root = (LinearLayout) findViewById(android.R.id.list).getParent().getParent().getParent();
        bar = (Toolbar) LayoutInflater.from(this).inflate(R.layout.settings_toolbar, root, false);
        root.addView(bar, 0); // insert at top
    } else {
        ViewGroup root = (ViewGroup) findViewById(android.R.id.content);
        ListView content = (ListView) root.getChildAt(0);
        root.removeAllViews();
        bar = (Toolbar) LayoutInflater.from(this).inflate(R.layout.settings_toolbar, root, false);

        int height;
        TypedValue tv = new TypedValue();
        if (getTheme().resolveAttribute(R.attr.actionBarSize, tv, true)) {
            height = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics());
        } else {
            height = bar.getHeight();
        }
        content.setPadding(0, height, 0, 0);

        root.addView(content);
        root.addView(bar);
    }
    bar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });
}

From source file:org.artoolkit.ar.samples.ARMovie.ARMovieActivity.java

/** Called when the activity is first created. */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override/*from   w  w  w .  j a  v a  2 s . c  om*/
public void onCreate(Bundle savedInstanceState) {
    Log.i(TAG, "onCreate()");
    super.onCreate(savedInstanceState);

    boolean needActionBar = false;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
            if (!ViewConfiguration.get(this).hasPermanentMenuKey())
                needActionBar = true;
        } else {
            needActionBar = true;
        }
    }
    if (needActionBar) {
        requestWindowFeature(Window.FEATURE_ACTION_BAR);
    } else {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    //setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); // Force landscape-only.
    updateNativeDisplayParameters();

    //Bundle extras = getIntent().getExtras();
    //String baseFolderPath = extras.getString("baseFolderPath");

    //int markerID = ARToolKit.getInstance().addMarker("multi;"+baseFolderPath +"/marker.dat");

    setContentView(R.layout.main_video);
    mButton = (Button) findViewById(R.id.button_capture);
    mButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //Toast.makeText(ARCloud.this, "Take picture", Toast.LENGTH_LONG).show();
            LinearLayout linearLayoutResultWrapper = (LinearLayout) findViewById(R.id.result_wrapper);
            if (linearLayoutResultWrapper.getChildCount() > 0) {
                linearLayoutResultWrapper.removeViewAt(0);
                linearLayoutResultWrapper.removeAllViews();
            }

            camSurface.getCamera().takePicture(null, null, mPicture);
            ;
        }
    });

    ARMovieActivity.nativeCreate(this);
}

From source file:com.todoroo.astrid.actfm.TagViewFragment.java

private void setUpMembersGallery() {
    LinearLayout membersView = (LinearLayout) getView().findViewById(R.id.shared_with);
    membersView.setOnClickListener(settingsListener);
    try {/*  ww w  .  ja  v  a 2s  .c o m*/
        String membersString = tagData.getValue(TagData.MEMBERS);
        JSONArray members = new JSONArray(membersString);
        if (members.length() > 0) {
            membersView.setOnClickListener(null);
            membersView.removeAllViews();
            for (int i = 0; i < members.length(); i++) {
                JSONObject member = members.getJSONObject(i);
                addImageForMember(membersView, member);
            }
            // Handle creator
            JSONObject owner;
            if (tagData.getValue(TagData.USER_ID) != 0) {
                owner = new JSONObject(tagData.getValue(TagData.USER));
            } else {
                owner = ActFmPreferenceService.thisUser();
            }
            addImageForMember(membersView, owner);

            JSONObject unassigned = new JSONObject();
            unassigned.put("id", Task.USER_ID_UNASSIGNED); //$NON-NLS-1$
            unassigned.put("name", getActivity().getString(R.string.actfm_EPA_unassigned)); //$NON-NLS-1$
            addImageForMember(membersView, unassigned);
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    getView().findViewById(R.id.filter_assigned).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            resetAssignedFilter();
        }
    });
}

From source file:com.github.howeyc.slideshow.activities.SettingsActivity.java

/************************************************************************************
*   needed because else the nested preference screen don't have a actionbar/toolbar *
*   see the fix and the given problem here: http://stackoverflow.com/a/27455363     *
************************************************************************************/
public void setUpNestedScreen(PreferenceScreen preferenceScreen) {
    final Dialog dialog = preferenceScreen.getDialog();
    //ViewGroup list;
    Toolbar bar;//from   w  w w .  ja va2s  .  co  m
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        //list = (ViewGroup) dialog.findViewById(android.R.id.list);
        LinearLayout root = (LinearLayout) dialog.findViewById(android.R.id.list).getParent();
        bar = (Toolbar) LayoutInflater.from(this).inflate(R.layout.settings_toolbar, root, false);
        root.addView(bar, 0); // insert at top
    } else {
        ViewGroup root = (ViewGroup) dialog.findViewById(android.R.id.content);
        ListView content = (ListView) root.getChildAt(0);
        //list = content;
        root.removeAllViews();
        bar = (Toolbar) LayoutInflater.from(this).inflate(R.layout.settings_toolbar, root, false);

        int height;
        TypedValue tv = new TypedValue();
        if (getTheme().resolveAttribute(R.attr.actionBarSize, tv, true)) {
            height = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics());
        } else {
            height = bar.getHeight();
        }

        content.setPadding(0, height, 0, 0);

        root.addView(content);
        root.addView(bar);
    }
    //list.addView(detailsPrefScreenToAdd.getStatusViewGroup(), 1); //TODO
    bar.setTitle(preferenceScreen.getTitle());
    dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialogI) {
            if (AppData.getLoginSuccessful()) {
                dialogI.dismiss();
            } else {
                showNotConnectedDialog(dialog);
            }
        }
    });
    bar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (AppData.getLoginSuccessful()) {
                dialog.dismiss();
            } else {
                showNotConnectedDialog(dialog);
            }
        }
    });
}

From source file:net.ddns.mlsoftlaberge.contactslist.ui.ContactsBudgetFragment.java

public void fillclientlayout(int clientno) {
    LinearLayout clayout = (LinearLayout) LayoutInflater.from(getActivity())
            .inflate(R.layout.contacts_budget_item, null, false);
    TextView id = (TextView) clayout.findViewById(R.id.budget_id);
    TextView name = (TextView) clayout.findViewById(R.id.budget_name);
    TextView phone = (TextView) clayout.findViewById(R.id.budget_phone);
    TextView email = (TextView) clayout.findViewById(R.id.budget_email);
    TextView address = (TextView) clayout.findViewById(R.id.budget_address);
    LinearLayout blayout = (LinearLayout) clayout.findViewById(R.id.budget_trans);
    id.setText(clientslist[clientno].id);
    name.setText(clientslist[clientno].name);
    phone.setText(clientslist[clientno].phone);
    email.setText(clientslist[clientno].email);
    address.setText(clientslist[clientno].address);
    blayout.removeAllViews();
    // loop thru all transactions of the client
    for (int i = 0; i < clientslist[clientno].nbtransac; ++i) {
        // Builds the transaction layout
        // Inflates the transaction layout
        LinearLayout tlayout = (LinearLayout) LayoutInflater.from(getActivity())
                .inflate(R.layout.contacts_budget_trans, null, false);
        TextView descrip = (TextView) tlayout.findViewById(R.id.budget_trans_descrip);
        TextView amount = (TextView) tlayout.findViewById(R.id.budget_trans_amount);
        // get the current transaction
        Transac transac = clientslist[clientno].transaclist.elementAt(i);
        // fill the fields with the table data
        descrip.setText(transac.descrip);
        amount.setText(transac.amount);//ww w  . j  av a 2 s . co m
        // cumulate the total amount
        gtot += Double.valueOf(transac.amount);
        // Adds the new note layout to the notes layout
        blayout.addView(tlayout, tlayoutParams);
    }
    // add the client layout in the budget layout
    budget_layout.addView(clayout, tlayoutParams);
}

From source file:fr.shywim.antoinedaniel.ui.MainActivity.java

private void createNavDrawerItems() {
    LinearLayout navDrawer = (LinearLayout) findViewById(R.id.nav_drawer);
    if (navDrawer == null) {
        return;//w w  w. j a  v  a  2s . c  o  m
    }

    mNavDrawerItemViews = new View[mNavDrawerItems.size()];
    navDrawer.removeAllViews();
    for (int i = 0; i < mNavDrawerItems.size(); i++) {
        mNavDrawerItemViews[i] = makeNavDrawerItem(mNavDrawerItems.get(i), navDrawer);
        navDrawer.addView(mNavDrawerItemViews[i]);
    }
}