Example usage for android.widget RelativeLayout removeAllViews

List of usage examples for android.widget RelativeLayout removeAllViews

Introduction

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

Prototype

public void removeAllViews() 

Source Link

Document

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

Usage

From source file:com.zt.hackman.model.HackmanModel.java

/**
 * ?//from  w w  w . j  a  v a  2 s .  c o m
 */
public void changeImage(ImageItem item, int current, RelativeLayout btn) {

    btn.removeAllViews();
    ImageView imageView = new ImageView(ac);
    imageView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    btn.addView(imageView);
    ImageLoader.getInstance().displayImage("file://" + item.path, imageView, BaseApp.options);
    switch (current) {
    case 1:
        response.idenFrontImage = new File(item.path);
        break;
    case 2:
        response.idenReserveImage = new File(item.path);
        break;
    case 3:
        response.driveImage = new File(item.path);
        break;
    case 4:
        response.driveImage2 = new File(item.path);
        break;
    case 5:
        response.doBusinessImage = new File(item.path);
        break;
    case 6:
        response.vehicleImg = new File(item.path);
        break;
    case 7:
        response.vehicleLicenseImg = new File(item.path);
        break;
    case 8:
        response.vehicleLicenseImg2 = new File(item.path);
        break;
    case 9:
        response.operationLicenseImg = new File(item.path);
        break;

    }

}

From source file:com.adwhirl.AdWhirlLayout.java

public void pushSubView(ViewGroup subView) {
    RelativeLayout superView = superViewReference.get();
    if (superView == null) {
        return;/*w w  w  . j  a v  a  2  s.  c  o  m*/
    }
    superView.removeAllViews();

    RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
            android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
    superView.addView(subView, layoutParams);

    Log.d(AdWhirlUtil.ADWHIRL, "Added subview");

    this.activeRation = nextRation;
    countImpression();
}

From source file:org.secuso.privacyfriendlydicegame.MainActivity.java

public void resetInterface() {
    roundCounter = 0;//from  w  w w  . ja v  a  2s .  c  o  m
    TextView roundCounterTextView = (TextView) findViewById(R.id.roundTextView);
    roundCounterTextView.setText(Integer.toString(roundCounter));

    for (int k = 0; k < isLocked.length; k++) {
        isLocked[k] = false;
    }

    for (int i = 0; i < dice.length; i++) {
        dice[i].setBackgroundDrawable(getResources().getDrawable(R.drawable.dice));
    }

    RelativeLayout diceContainer = (RelativeLayout) findViewById(R.id.dice_frame);
    RelativeLayout diceRowTwo = (RelativeLayout) findViewById(R.id.dice_frame_second);

    if (diceContainer.getChildCount() > 0)
        diceContainer.removeAllViews();
    if (diceRowTwo.getChildCount() > 0)
        diceRowTwo.removeAllViews();

    for (int i = 0; i < dice.length; i++) {
        dice[i].setBackground(getResources().getDrawable(R.drawable.invisible_button));
    }

    hints(0);

}

From source file:ac.robinson.ticqr.TicQRActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.action_send_order:
        sendOrder();//from w  w w  .  j av  a  2  s  .  c  o m
        return true;

    case R.id.action_rescan:
        // reset our configuration and set up for rescanning
        mBitmap = null;
        mDestinationEmail = null;
        mServerTickBoxes.clear();
        mImageTickBoxes.clear();

        mBoxesLoaded = false;
        mImageParsed = false;
        mEmailContents = null;

        mImageView.setVisibility(View.INVISIBLE); // must be invisible (not gone) as we need its dimensions
        RelativeLayout highlightHolder = (RelativeLayout) findViewById(R.id.tick_highlight_holder);
        highlightHolder.removeAllViews();

        getSupportActionBar().setTitle(R.string.title_activity_capture);
        supportInvalidateOptionsMenu();
        requestScanResume();
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:ca.ualberta.cmput301w14t08.geochan.fragments.ThreadViewFragment.java

/**
 * When a comment is clicked, this method deflates the additional 
 * (location and button) layout of other comments in the list.
 * //from w  w w .  java2  s. co m
 * TODO: make it also deflate the layouts of comments off the screen.
 * 
 * @param position The position of the Comment that will not be deflated.
 */
private void resetOtherCommentLayouts(int position) {
    for (int i = 2; i < threadView.getCount() + 1; ++i) {

        if (i == position + 1) {
            continue;
        }
        View v = threadView.getChildAt(i);
        if (v == null) {
            continue;
        }
        RelativeLayout relativeInflater = (RelativeLayout) v.findViewById(R.id.relative_inflater);
        if (relativeInflater != null && relativeInflater.getChildCount() > 0) {
            relativeInflater.removeAllViews();
        }
    }

}

From source file:com.frostwire.android.gui.activities.MainActivity2.java

private void updateHeader(Fragment fragment) {
    try {// w  ww.ja  v a 2  s .  c  o  m
        RelativeLayout placeholder = (RelativeLayout) getActionBar().getCustomView();
        if (placeholder != null && placeholder.getChildCount() > 0) {
            placeholder.removeAllViews();
        }

        if (fragment instanceof MainFragment) {
            View header = ((MainFragment) fragment).getHeader(this);
            if (placeholder != null && header != null) {
                RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                        LayoutParams.WRAP_CONTENT);
                params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
                placeholder.addView(header, params);
            }
        }
    } catch (Throwable e) {
        LOG.error("Error updating main header", e);
    }
}

From source file:com.bt.download.android.gui.activities.MainActivity.java

private void updateHeader(Fragment fragment) {
    try {//from  w w w . ja v a 2s . c  om
        RelativeLayout placeholder = (RelativeLayout) getActionBar().getCustomView();//findView(R.id.activity_main_layout_header_placeholder);
        if (placeholder != null && placeholder.getChildCount() > 0) {
            placeholder.removeAllViews();
        }

        if (fragment instanceof MainFragment) {
            View header = ((MainFragment) fragment).getHeader(this);
            if (placeholder != null && header != null) {
                RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                        LayoutParams.WRAP_CONTENT);
                params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
                placeholder.addView(header, params);
            }
        }
    } catch (Throwable e) {
        LOG.error("Error updating main header", e);
    }
}

From source file:org.dkf.jmule.activities.MainActivity.java

private void updateHeader(Fragment fragment) {
    try {/*from  www. j a  v  a 2 s  .  c  om*/
        RelativeLayout placeholder = (RelativeLayout) getActionBar().getCustomView();
        if (placeholder != null && placeholder.getChildCount() > 0) {
            placeholder.removeAllViews();
        }

        if (fragment instanceof MainFragment) {
            View header = ((MainFragment) fragment).getHeader(this);
            if (placeholder != null && header != null) {
                RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                        LayoutParams.WRAP_CONTENT);
                params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
                placeholder.addView(header, params);
            }
        }
    } catch (Exception e) {
        log.error("Error updating main header", e);
    }
}

From source file:org.secuso.privacyfriendlydicegame.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);/*from   w ww. jav  a2 s .com*/

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar,
            R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    hints(0);

    Display display = getWindowManager().getDefaultDisplay();
    setSizes(display.getWidth() / 40, Math.round(display.getWidth() / 4));

    final TextView finalResult = (TextView) findViewById(R.id.resultTextView);

    Button rollDiceButtonNotFinal = (Button) findViewById(R.id.button);
    rollDiceButtonNotFinal.setText(getString(R.string.roll_button));

    dice = new Button[5];
    dice[0] = (Button) findViewById(R.id.button_dice_one);
    dice[1] = (Button) findViewById(R.id.button_dice_two);
    dice[2] = (Button) findViewById(R.id.button_dice_three);
    dice[3] = (Button) findViewById(R.id.button_dice_four);
    dice[4] = (Button) findViewById(R.id.button_dice_five);

    for (int i = 0; i < dice.length; i++) {
        dice[i].setWidth(Math.round(diceSize));
        dice[i].setHeight(Math.round(diceSize));
    }

    isLocked = new boolean[5];
    for (int k = 0; k < isLocked.length; k++) {
        isLocked[k] = false;
    }

    for (int i = 0; i < dice.length; i++) {
        dice[i].setBackground(getResources().getDrawable(R.drawable.invisible_button));
    }

    oldResults = new int[] { 1, 2, 3, 4, 5 };
    backResults = new int[] { 1, 2, 3, 4, 5 };

    roundCounter = 0;

    final RelativeLayout diceContainer = (RelativeLayout) findViewById(R.id.dice_frame);
    final RelativeLayout diceRowTwo = (RelativeLayout) findViewById(R.id.dice_frame_second);

    //buttons
    final Button rollDiceButton = (Button) findViewById(R.id.button);
    rollDiceButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            if (allTrue(isLocked)) {
                for (int k = 0; k < dice.length; k++) {
                    dice[k].setBackground(getResources().getDrawable(R.drawable.dice_final));
                }
                finalResult.setVisibility(View.VISIBLE);
                rollDiceButton.setText(getString(R.string.new_round_button));
                roundCounter = 3;
                for (int k = 0; k < isLocked.length; k++) {
                    isLocked[k] = false;
                }
            } else {

                if (diceContainer.getChildCount() > 0)
                    diceContainer.removeAllViews();
                if (diceRowTwo.getChildCount() > 0)
                    diceRowTwo.removeAllViews();
                setDice(rollDice(5));

                if (roundCounter == 0) {
                    for (int k = 0; k < dice.length; k++) {
                        dice[k].setBackground(getResources().getDrawable(R.drawable.dice));
                    }
                }

                if (roundCounter == 2) {
                    for (int k = 0; k < dice.length; k++) {
                        dice[k].setBackground(getResources().getDrawable(R.drawable.dice_final));
                    }
                    finalResult.setVisibility(View.VISIBLE);
                    rollDiceButton.setText(getString(R.string.new_round_button));
                }

                if (roundCounter == 3) {
                    resetInterface();
                    finalResult.setVisibility(View.INVISIBLE);
                    rollDiceButton.setText(getString(R.string.roll_button));

                } else {
                    roundCounter++;
                }
                TextView roundCounterTextView = (TextView) findViewById(R.id.roundTextView);
                roundCounterTextView.setText(Integer.toString(roundCounter));
                flashResult();
            }
        }
    });

    Button resetButton = (Button) findViewById(R.id.resetButton);
    resetButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            if (roundCounter != 0) {
                resetInterface();
                finalResult.setVisibility(View.INVISIBLE);
            }

        }
    });

    for (int j = 0; j < dice.length; j++) {
        final int finalJ = j;
        dice[j].setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                if (roundCounter == 0) {
                } else if (roundCounter != 3) {
                    setLock(finalJ, v);
                }
            }
        });
    }

}