Example usage for android.widget LinearLayout removeAllViewsInLayout

List of usage examples for android.widget LinearLayout removeAllViewsInLayout

Introduction

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

Prototype

public void removeAllViewsInLayout() 

Source Link

Document

Called by a ViewGroup subclass to remove child views from itself, when it must first know its size on screen before it can calculate how many child views it will render.

Usage

From source file:org.onebusaway.android.ui.TutorialFragment.java

private void updatePagerIndicator(int position, int size) {
    LinearLayout linear = (LinearLayout) getActivity().findViewById(R.id.pager_indicator);
    linear.removeAllViewsInLayout();

    for (int i = 0; i < size; i++) {
        ImageView iw = new ImageView(getActivity());
        if (position == i) {
            iw.setImageResource(R.drawable.pager_dot_hover);
        } else {//from  w  ww  . ja v a  2 s.com
            iw.setImageResource(R.drawable.pager_dot);
        }

        iw.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT));
        LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) iw.getLayoutParams();
        params.setMargins(5, 0, 0, 0);
        iw.setLayoutParams(params);

        linear.addView(iw);
    }
}

From source file:com.bytestemplar.tonedef.international.ButtonsFragment.java

public void updateButtons(int position) {
    LinearLayout ll_btn_container = (LinearLayout) getView().findViewById(R.id.buttons_container);

    if (ll_btn_container != null) {

        _current_position = position;/*  w  w w. j  av a 2 s. c  o  m*/
        CountryTones current_tones = CountryTonesRepository.getInstance().getCountryAtPosition(position);

        ll_btn_container.removeAllViewsInLayout();

        // Update label
        TextView tv_name = (TextView) getView().findViewById(R.id.tv_countryname);
        tv_name.setText(current_tones.getName());
        tv_name.setTypeface(UICustom.getInstance().getTypeface());
        if (current_tones.getFlagDrawable() > 0) {
            tv_name.setCompoundDrawablesWithIntrinsicBounds(current_tones.getFlagDrawable(), 0, 0, 0);
        }

        // Generate buttons
        HashMap<String, ToneSequence> sequences = current_tones.getSequences();

        for (Object o : sequences.entrySet()) {
            Map.Entry pair = (Map.Entry) o;

            String sequence_name = (String) pair.getKey();
            final ToneSequence sequence = (ToneSequence) pair.getValue();

            Button btn = new Button(ll_btn_container.getContext());
            btn.setText(sequence_name);
            btn.setTypeface(UICustom.getInstance().getTypeface());
            btn.setBackgroundResource(R.drawable.touchpadbutton);
            btn.setTextColor(Color.WHITE);
            btn.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    switch (event.getAction()) {
                    case MotionEvent.ACTION_DOWN:
                        sequence.start();
                        v.setBackgroundResource(R.drawable.touchpadbutton_selected);
                        break;
                    case MotionEvent.ACTION_UP:
                    case MotionEvent.ACTION_CANCEL:
                        sequence.stop();
                        v.setBackgroundResource(R.drawable.touchpadbutton);
                        break;
                    }
                    return false;
                }
            });
            btn.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT));
            ll_btn_container.addView(btn);
        }
    }
}

From source file:cc.softwarefactory.lokki.android.fragments.PlacesFragment.java

private void setListAdapter() {

    Log.d(TAG, "setListAdapter");

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(context, R.layout.places_row_layout, placesList) {

        @Override/*from  w ww .ja va 2  s . c o  m*/
        public View getView(int position, View unusedView, ViewGroup parent) {

            View convertView = getActivity().getLayoutInflater().inflate(R.layout.places_row_layout, parent,
                    false);
            AQuery aq = new AQuery(getActivity(), convertView);

            final String placeName = getItem(position);
            aq.id(R.id.place_name).text(placeName);

            aq.id(R.id.places_context_menu_button).clicked(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    v.showContextMenu();
                }
            });

            Log.d(TAG, "Plane name: " + placeName);
            Log.d(TAG, "peopleInsidePlace? " + peopleInsidePlace.has(placeName));

            if (peopleInsidePlace.has(placeName)) { // People are inside this place
                Log.d(TAG, "Inside loop");
                try {
                    JSONArray people = peopleInsidePlace.getJSONArray(placeName);
                    LinearLayout avatarRow = (LinearLayout) convertView.findViewById(R.id.avatar_row);
                    avatarRow.removeAllViewsInLayout(); // Deletes old avatars, if any.

                    for (int i = 0; i < people.length(); i++) {

                        final String email = people.getString(i);
                        if (MainApplication.iDontWantToSee.has(email)) {
                            continue;
                        }
                        RoundedImageView image = createAvatar(email);

                        if (MainApplication.avatarCache.get(email) != null) {
                            image.setImageBitmap(MainApplication.avatarCache.get(email));
                        } else {
                            Log.d(TAG, "Avatar not in cache, email: " + email);
                            image.setImageResource(R.drawable.default_avatar);
                        }
                        image.setContentDescription(email);

                        avatarRow.addView(image);
                    }

                } catch (Exception ex) {
                    Log.d(TAG, "Error in adding avatars");
                }
            }

            return convertView;
        }
    };

    listView.setAdapter(adapter);

}

From source file:io.github.trulyfree.easyaspi.MainActivity.java

/**
 * Helper method which refreshes the module layout between module downloads/deletions.
 *///from ww  w . j a v  a  2 s  . c om
private void refreshFilling() {
    LinearLayout dashboard = (LinearLayout) findViewById(R.id.dashboard);
    dashboard.removeAllViewsInLayout();
    if (moduleHandler.getConfigs().length != 0) {
        final LinearLayout moduleList = (LinearLayout) ((LinearLayout) getLayoutInflater()
                .inflate(R.layout.modulelist, dashboard)).getChildAt(0);
        final Button refreshAll = (Button) findViewById(R.id.refresh_all);
        refreshAll.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Toast.makeText(MainActivity.this, "Refreshing jars...", Toast.LENGTH_SHORT).show();
                executorService.submit(new Callable<Boolean>() {
                    @Override
                    public Boolean call() {
                        boolean success = true;
                        refreshAll.setClickable(false);
                        final TextView stager = (TextView) findViewById(R.id.refresh_download_stage);
                        final ProgressBar progressBar = (ProgressBar) findViewById(R.id.refresh_bar);
                        try {
                            moduleHandler.refreshAll(makeModuleCallback(stager, progressBar));
                        } catch (IOException e) {
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    Toast.makeText(MainActivity.this, "Refresh failed. :(", Toast.LENGTH_SHORT)
                                            .show();
                                    stager.setText("");
                                    progressBar.setProgress(0);
                                }
                            });
                            success = false;
                        }
                        refreshAll.setClickable(true);
                        return success;
                    }
                });
            }
        });
        LinearLayout scrolledModuleList = (LinearLayout) ((ScrollView) moduleList.getChildAt(3)).getChildAt(0);
        for (int i = 0; i < moduleHandler.getConfigs().length; i++) {
            final int intermediary = i;
            final LinearLayout layout = (LinearLayout) ((LinearLayout) getLayoutInflater()
                    .inflate(R.layout.module, scrolledModuleList)).getChildAt(i);
            executorService.submit(new Callable<Boolean>() {
                @Override
                public Boolean call() {
                    final Button launcher = (Button) layout.getChildAt(1);
                    final Button delete = (Button) layout.getChildAt(2);
                    launcher.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            Intent myIntent = new Intent(MainActivity.this, EAPDisplay.class);
                            myIntent.putExtra("targetModule",
                                    moduleHandler.toJson(moduleHandler.getConfigs()[intermediary]));
                            MainActivity.this.startActivityForResult(myIntent, intermediary);
                        }
                    });
                    delete.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            ModuleConfig config = moduleHandler.getConfigs()[intermediary];
                            boolean success = false;
                            try {
                                success = moduleHandler.remove(null, config);
                            } catch (IOException e) {
                                e.printStackTrace();
                            }
                            final String toast = "Deletion of " + config.getName() + " was "
                                    + ((success) ? "successful." : "unsuccessful.");
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    Toast.makeText(MainActivity.this, toast, Toast.LENGTH_SHORT).show();
                                    refreshFilling();
                                }
                            });
                        }
                    });
                    launcher.setClickable(true);
                    delete.setClickable(true);
                    return true;
                }
            });
            EditText moduleName = (EditText) layout.getChildAt(0);
            moduleName.setText(moduleHandler.getConfigs()[intermediary].getName());
        }
    } else {
        getLayoutInflater().inflate(R.layout.no_module_modulelist, dashboard);
    }
}

From source file:io.github.trulyfree.easyaspi.MainActivity.java

@Override
public boolean setup() {
    downloadHandler = new DownloadHandler(this);
    fileHandler = new FileHandler(this);
    moduleHandler = new ModuleHandler(this);
    executorService = Executors.newCachedThreadPool();

    setContentView(R.layout.activity_main);
    BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
    navigation.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {

        @Override/*w  w w .ja  v  a  2  s. c  o m*/
        public boolean onNavigationItemSelected(@NonNull MenuItem item) {
            ViewSwitcher viewGroup = (ViewSwitcher) findViewById(R.id.content);
            int id = item.getItemId();
            if ((id == R.id.navigation_home || id == R.id.navigation_modules) && id != currentID) {
                currentID = item.getItemId();
                viewGroup.showNext();
                return true;
            }
            return false;
        }

    });

    ViewSwitcher viewSwitcher = (ViewSwitcher) findViewById(R.id.content);
    Animation in = AnimationUtils.loadAnimation(this, android.R.anim.slide_in_left);
    Animation out = AnimationUtils.loadAnimation(this, android.R.anim.slide_out_right);
    viewSwitcher.setInAnimation(in);
    viewSwitcher.setOutAnimation(out);

    resetConfigReturned();

    Button getNewModule = (Button) findViewById(R.id.new_module_config_confirm);
    getNewModule.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            EditText editText = (EditText) findViewById(R.id.new_module_config_configurl);
            final String url = editText.getText().toString();
            Toast.makeText(MainActivity.this, "Requested config from: " + url, Toast.LENGTH_SHORT).show();
            executorService.submit(new Callable<Boolean>() {
                @Override
                public Boolean call() {
                    ModuleConfig config;
                    try {
                        config = moduleHandler.getModuleConfig(url);
                    } catch (MalformedURLException e) {
                        e.printStackTrace();
                        runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                Toast.makeText(MainActivity.this, "Invalid URL. :(", Toast.LENGTH_LONG).show();
                            }
                        });
                        return false;
                    } catch (IOException e) {
                        e.printStackTrace();
                        runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                Toast.makeText(MainActivity.this, "Failed to get module config. :(",
                                        Toast.LENGTH_LONG).show();
                            }
                        });
                        return false;
                    } catch (JsonParseException e) {
                        e.printStackTrace();
                        runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                Toast.makeText(MainActivity.this, "Config loaded was invalid. :(",
                                        Toast.LENGTH_LONG).show();
                            }
                        });
                        return false;
                    }

                    final ModuleConfig finalConfig = config;
                    final ImageView configResponseBlock = (ImageView) findViewById(R.id.block_module_returned);
                    final int colorFrom = ContextCompat.getColor(MainActivity.this, R.color.colorFillingTint);
                    final int colorTo = ContextCompat.getColor(MainActivity.this, R.color.colorClear);
                    final ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom,
                            colorTo);
                    colorAnimation.setDuration(ANIMATION_DURATION);
                    colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                        @Override
                        public void onAnimationUpdate(ValueAnimator animator) {
                            configResponseBlock.setBackgroundColor((Integer) animator.getAnimatedValue());
                        }
                    });
                    colorAnimation.addListener(new Animator.AnimatorListener() {
                        @Override
                        public void onAnimationStart(Animator animator) {
                        }

                        @Override
                        public void onAnimationEnd(Animator animator) {
                            LinearLayout layout = (LinearLayout) findViewById(R.id.module_returned_config);
                            EditText moduleName = (EditText) findViewById(R.id.module_returned_configname);
                            EditText moduleVersion = (EditText) findViewById(
                                    R.id.module_returned_configversion);
                            EditText moduleConfigUrl = (EditText) findViewById(R.id.module_returned_configurl);
                            EditText moduleJarUrl = (EditText) findViewById(R.id.module_returned_jarurl);
                            LinearLayout moduleDependencies = (LinearLayout) findViewById(
                                    R.id.module_returned_dependencies);
                            moduleDependencies.removeAllViewsInLayout();
                            try {
                                configResponseBlock.setVisibility(View.GONE);
                                moduleName.setText(finalConfig.getName());
                                moduleVersion.setText(finalConfig.getVersion());
                                moduleConfigUrl.setText(finalConfig.getConfUrl());
                                moduleJarUrl.setText(finalConfig.getJarUrl());
                                Config[] dependencies = finalConfig.getDependencies();
                                for (Config dependency : dependencies) {
                                    LinearLayout dependencyLayout = new LinearLayout(MainActivity.this);
                                    dependencyLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,
                                            LayoutParams.WRAP_CONTENT));
                                    dependencyLayout.setOrientation(LinearLayout.HORIZONTAL);
                                    EditText name = new EditText(MainActivity.this);
                                    EditText jarUrl = new EditText(MainActivity.this);
                                    EditText[] loopThrough = { name, jarUrl };
                                    LayoutParams params = new LayoutParams(0, LayoutParams.WRAP_CONTENT, 1.0f);
                                    for (EditText item : loopThrough) {
                                        item.setLayoutParams(params);
                                        item.setClickable(false);
                                        item.setInputType(InputType.TYPE_NULL);
                                        item.setCursorVisible(false);
                                        item.setFocusable(false);
                                        item.setFocusableInTouchMode(false);
                                    }
                                    name.setText(dependency.getName());
                                    jarUrl.setText(dependency.getJarUrl());
                                    dependencyLayout.addView(name);
                                    dependencyLayout.addView(jarUrl);
                                    moduleDependencies.addView(dependencyLayout);
                                }
                                layout.setClickable(true);
                                Button validate = (Button) findViewById(R.id.module_returned_validate);
                                Button cancel = (Button) findViewById(R.id.module_returned_cancel);
                                validate.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        Toast.makeText(MainActivity.this, "Requesting jars...",
                                                Toast.LENGTH_SHORT).show();
                                        executorService.submit(new Callable<Boolean>() {
                                            @Override
                                            public Boolean call() {
                                                try {
                                                    boolean success = true, refreshAllModification = true;
                                                    Button refreshAll = null,
                                                            getNewModule = (Button) findViewById(
                                                                    R.id.new_module_config_confirm);
                                                    try {
                                                        refreshAll = (Button) findViewById(R.id.refresh_all);
                                                        refreshAll.setClickable(false);
                                                    } catch (Throwable e) {
                                                        refreshAllModification = false;
                                                    }
                                                    getNewModule.setClickable(false);
                                                    final TextView stager = (TextView) findViewById(
                                                            R.id.new_module_config_downloadstage);
                                                    final ProgressBar progressBar = (ProgressBar) findViewById(
                                                            R.id.new_module_config_downloadprogress);
                                                    try {
                                                        runOnUiThread(new Runnable() {
                                                            @Override
                                                            public void run() {
                                                                resetConfigReturned();
                                                            }
                                                        });
                                                        moduleHandler.getNewModule(
                                                                makeModuleCallback(stager, progressBar),
                                                                finalConfig, null, true);
                                                    } catch (IOException e) {
                                                        e.printStackTrace();
                                                        runOnUiThread(new Runnable() {
                                                            @Override
                                                            public void run() {
                                                                stager.setText("");
                                                                progressBar.setProgress(0);
                                                            }
                                                        });
                                                        success = false;
                                                    }
                                                    getNewModule.setClickable(true);
                                                    if (refreshAllModification) {
                                                        refreshAll.setClickable(true);
                                                    }
                                                    return success;
                                                } catch (Throwable throwable) {
                                                    throwable.printStackTrace();
                                                    return false;
                                                }
                                            }
                                        });
                                    }
                                });
                                cancel.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        Toast.makeText(MainActivity.this, "Cancelling request...",
                                                Toast.LENGTH_SHORT).show();
                                        resetConfigReturned();
                                    }
                                });
                            } catch (Exception e) {
                                e.printStackTrace();
                                Toast.makeText(MainActivity.this, "Module config invalid. :(",
                                        Toast.LENGTH_LONG).show();
                                layout.setClickable(false);
                                final int colorFrom = ContextCompat.getColor(MainActivity.this,
                                        R.color.colorClear);
                                final int colorTo = ContextCompat.getColor(MainActivity.this,
                                        R.color.colorFillingTint);
                                ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(),
                                        colorFrom, colorTo);
                                colorAnimation.setDuration(ANIMATION_DURATION);
                                colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                                    @Override
                                    public void onAnimationUpdate(ValueAnimator animator) {
                                        configResponseBlock
                                                .setBackgroundColor((Integer) animator.getAnimatedValue());
                                    }
                                });
                            }
                        }

                        @Override
                        public void onAnimationCancel(Animator animator) {
                        }

                        @Override
                        public void onAnimationRepeat(Animator animator) {
                        }
                    });
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            colorAnimation.start();
                        }
                    });
                    return true;
                }
            });
        }
    });

    moduleHandler.setup();
    refreshFilling();
    return true;
}

From source file:com.raspi.chatapp.ui.chatting.SendImageFragment.java

/**
 * this function will initialize the ui showing the current image and reload
 * everything to make sure it is shown correctly
 *//*ww w.  j  a va  2s . c  om*/
private void initUI() {
    // set the actionBar title and subtitle
    if (actionBar != null) {
        actionBar.setTitle(R.string.send_image);
        actionBar.setSubtitle(name);
        //      actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor
        //              (R.color.action_bar_transparent)));
        //      // set the statusBar color
        //      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        //        getActivity().getWindow().setStatusBarColor(getResources().getColor(R
        //                .color.action_bar_transparent));
    }

    // instantiate the ViewPager
    viewPager = (ViewPager) getActivity().findViewById(R.id.send_image_view_pager);
    viewPager.setAdapter(new MyPagerAdapter());
    viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        }

        @Override
        public void onPageSelected(int position) {
            changePage(position, false, false);
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }
    });

    //Cancel button pressed
    getView().findViewById(R.id.send_image_cancel).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // just return to the chatFragment
            mListener.onReturnClick();
        }
    });
    //Send button pressed
    getView().findViewById(R.id.send_image_send).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // create the progressDialog that is to be shown while saving
            // the image
            ProgressDialog progressDialog = new ProgressDialog(getContext());
            if (images.size() > 1)
                progressDialog.setTitle(
                        String.format(getResources().getString(R.string.sending_images), images.size()));
            else
                progressDialog.setTitle(R.string.sending_image);
            // run the sendImage in a new thread because I am saving the
            // image and this should be done in a new thread
            new Thread(new SendImagesRunnable(new Handler(), getContext(), progressDialog)).start();
        }
    });

    // generate the overview only if there are at least 2 images
    if (images.size() > 1) {
        // the layoutParams for the imageView which has the following attributes:
        // width = height = 65dp
        // margin = 5dp
        getActivity().findViewById(R.id.send_image_overview).setVisibility(View.VISIBLE);
        int a = Constants.dipToPixel(getContext(), 65);
        RelativeLayout.LayoutParams imageViewParams = new RelativeLayout.LayoutParams(a, a);
        int b = Constants.dipToPixel(getContext(), 5);
        imageViewParams.setMargins(b, b, b, b);
        // the layoutParams for the backgroundView which has the following
        // attributes:
        // width = height = 71dp
        // margin = 2dp
        int c = Constants.dipToPixel(getContext(), 71);
        RelativeLayout.LayoutParams backgroundParams = new RelativeLayout.LayoutParams(c, c);
        int d = Constants.dipToPixel(getContext(), 2);
        backgroundParams.setMargins(d, d, d, d);
        // the layoutParams for the relativeLayout containing the image and
        // the background which has the following attributes:
        // width = height = wrap_content
        LinearLayout.LayoutParams relativeLayoutParams = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        LinearLayout linearLayout = (LinearLayout) getActivity().findViewById(R.id.send_image_overview_content);
        linearLayout.removeAllViewsInLayout();
        int i = 0;
        for (Message msg : images) {
            // set up the imageView
            ImageView imageView = new ImageView(getContext());
            imageView.setLayoutParams(imageViewParams);
            imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
            // load the bitmap async
            AsyncDrawable.BitmapWorkerTask bitmapWorker = new AsyncDrawable.BitmapWorkerTask(imageView, a, a,
                    true);
            imageView.setImageDrawable(new AsyncDrawable(getResources(), null, bitmapWorker));
            imageView.setOnClickListener(new overviewSelectListener(i++));
            bitmapWorker.execute(FileUtils.getFile(getContext(), msg.getImageUri()));
            // set up the background
            View background = new View(getContext());
            background.setLayoutParams(backgroundParams);
            background.setBackgroundColor(getActivity().getResources().getColor(R.color.colorPrimaryDark));
            // make it invisible in the beginning
            background.setVisibility(View.GONE);

            // create the relativeLayout containing them
            RelativeLayout relativeLayout = new RelativeLayout(getContext());
            relativeLayout.setLayoutParams(relativeLayoutParams);
            relativeLayout.addView(background);
            relativeLayout.addView(imageView);
            // combination of Message and overviewViews
            msg.setLayout(relativeLayout);
            msg.setBackground(background);
            linearLayout.addView(relativeLayout);
        }
    } else
        getActivity().findViewById(R.id.send_image_overview).setVisibility(View.GONE);
    changePage(current, true, true);
    showSystemUI();
}

From source file:io.github.trulyfree.easyaspi.MainActivity.java

/**
 *
 *//*from  w  ww. j  a va2s . c o  m*/
private void resetConfigReturned() {
    final ImageView configResponseBlock = (ImageView) findViewById(R.id.block_module_returned);
    LinearLayout layout = (LinearLayout) findViewById(R.id.module_returned_config);
    EditText moduleName = (EditText) findViewById(R.id.module_returned_configname);
    EditText moduleVersion = (EditText) findViewById(R.id.module_returned_configversion);
    EditText moduleConfigUrl = (EditText) findViewById(R.id.module_returned_configurl);
    EditText moduleJarUrl = (EditText) findViewById(R.id.module_returned_jarurl);
    LinearLayout moduleDependencies = (LinearLayout) findViewById(R.id.module_returned_dependencies);
    Button validate = (Button) findViewById(R.id.module_returned_validate);
    Button cancel = (Button) findViewById(R.id.module_returned_cancel);
    moduleName.setText(R.string.module_returned_configname);
    moduleVersion.setText(R.string.module_returned_configversion);
    moduleConfigUrl.setText(R.string.module_returned_configurl);
    moduleJarUrl.setText(R.string.module_returned_jarurl);
    moduleDependencies.removeAllViewsInLayout();
    validate.setOnClickListener(null);
    cancel.setOnClickListener(null);
    final int colorFrom = ContextCompat.getColor(MainActivity.this, R.color.colorClear);
    final int colorTo = ContextCompat.getColor(MainActivity.this, R.color.colorFillingTint);
    ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
    colorAnimation.setDuration(ANIMATION_DURATION);
    colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animator) {
            configResponseBlock.setBackgroundColor((Integer) animator.getAnimatedValue());
        }
    });
    layout.setClickable(false);
    configResponseBlock.setVisibility(View.VISIBLE);
    colorAnimation.start();
}

From source file:com.google.example.eightbitartist.DrawingActivity.java

/**
 * Show a small view for each connected player with their picture, name, and score.
 *//*  w w w .  j a  v a  2 s  .co  m*/
private void setUpPlayerViews() {
    // Remove all existing views (note that removing and re-adding all views is not very
    // efficient and you should not do it in your own application).
    LinearLayout playerViews = (LinearLayout) findViewById(R.id.playerViews);
    playerViews.removeAllViewsInLayout();

    // Sort the list to determine which player is the artist so we can highlight that view
    List<String> ids = new ArrayList<>();
    ids.addAll(mParticipants.keySet());
    Collections.sort(ids);
    int artistIndex = mMatchTurnNumber % ids.size();
    String artistId = ids.get(artistIndex);

    // Create a PlayerView for each participant
    for (DrawingParticipant participant : mParticipants.values()) {
        PlayerView playerView = new PlayerView(this);
        playerView.populateWithParticipant(participant);
        playerView.setIsArtist(participant.getPersistentId().equals(artistId));
        playerViews.addView(playerView);
    }
}