Example usage for android.widget LinearLayout findViewById

List of usage examples for android.widget LinearLayout findViewById

Introduction

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

Prototype

@Nullable
public final <T extends View> T findViewById(@IdRes int id) 

Source Link

Document

Finds the first descendant view with the given ID, the view itself if the ID matches #getId() , or null if the ID is invalid (< 0) or there is no matching view in the hierarchy.

Usage

From source file:org.ounl.lifelonglearninghub.fcube.navigate.SwipeFragmentActivity.java

/**
 * On click one color radiobutton, deselect the rest of the radiobuttons
 * //w  w  w  .  j a  v a  2s.c  o m
 * @param v
 */
public void onSelectColorRadioButton(View v) {

    LinearLayout llRadioButton = (LinearLayout) v.getParent();
    LinearLayout llRoot = (LinearLayout) llRadioButton.getParent();

    RadioButton rbF = (RadioButton) llRoot.findViewById(R.id.rbFullColor);
    RadioButton rbP = (RadioButton) llRoot.findViewById(R.id.rbPartColor);

    String sTag = v.getTag().toString();
    if (getString(R.string.rb_fully).compareTo(sTag) == 0) {

        rbP.setChecked(false);

    } else if (getString(R.string.rb_partly).compareTo(sTag) == 0) {

        rbF.setChecked(false);

    }

}

From source file:com.example.android.wearable.quiz.MainActivity.java

/**
 * Resets the current quiz when Reset Quiz is pressed.
 *///from  w  w  w  .ja  v  a  2  s  . c o  m
public void resetQuiz(View view) {
    // Reset quiz status in phone layout.
    for (int i = 0; i < questionsContainer.getChildCount(); i++) {
        LinearLayout questionStatusElement = (LinearLayout) questionsContainer.getChildAt(i);
        TextView questionText = (TextView) questionStatusElement.findViewById(R.id.question);
        TextView questionStatus = (TextView) questionStatusElement.findViewById(R.id.status);
        questionText.setTextColor(Color.WHITE);
        questionStatus.setText(R.string.question_unanswered);
    }
    // Reset data items and notifications on wearable.
    if (mGoogleApiClient.isConnected()) {
        Wearable.DataApi.getDataItems(mGoogleApiClient).setResultCallback(new ResultCallback<DataItemBuffer>() {
            @Override
            public void onResult(DataItemBuffer result) {
                try {
                    if (result.getStatus().isSuccess()) {
                        resetDataItems(result);
                    } else {
                        if (Log.isLoggable(TAG, Log.DEBUG)) {
                            Log.d(TAG, "Reset quiz: failed to get Data Items to reset");
                        }
                    }
                } finally {
                    result.release();
                }
            }
        });
    } else {
        Log.e(TAG, "Failed to reset data items because client is disconnected from " + "Google Play Services");
    }
    setHasQuestionBeenAsked(false);
    mNumCorrect = 0;
    mNumIncorrect = 0;
    mNumSkipped = 0;
}

From source file:com.offsec.nethunter.AppNavHomeActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    // ************************************************
    c = getApplication(); //* DONT REMOVE ME *
    // ************************************************
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        askMarshmallowPerms(permsCurrent);
    } else {/*  w  w  w.jav  a2 s. c  o m*/
        CheckForRoot mytask = new CheckForRoot(this);
        mytask.execute();
    }

    setContentView(R.layout.base_layout);

    //set kali wallpaper as background
    ActionBar ab = getSupportActionBar();
    if (ab != null) {
        ab.setHomeButtonEnabled(true);
        ab.setDisplayHomeAsUpEnabled(true);
    }
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

    navigationView = (NavigationView) findViewById(R.id.navigation_view);
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    LinearLayout navigationHeadView = (LinearLayout) inflater.inflate(R.layout.sidenav_header, null);
    navigationView.addHeaderView(navigationHeadView);

    FloatingActionButton readmeButton = (FloatingActionButton) navigationHeadView.findViewById(R.id.info_fab);
    readmeButton.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            //checkUpdate();
            showLicense();
            return false;
        }
    });

    /// moved build info to the menu
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd KK:mm:ss a zzz", Locale.US);

    prefs = getSharedPreferences("com.offsec.nethunter", Context.MODE_PRIVATE);

    final String buildTime = sdf.format(BuildConfig.BUILD_TIME);
    TextView buildInfo1 = (TextView) navigationHeadView.findViewById(R.id.buildinfo1);
    TextView buildInfo2 = (TextView) navigationHeadView.findViewById(R.id.buildinfo2);
    buildInfo1.setText(String.format("Version: %s (%s)", BuildConfig.VERSION_NAME, Build.TAGS));
    buildInfo2.setText(String.format("Built by %s at %s", BuildUser, buildTime));

    if (navigationView != null) {
        setupDrawerContent(navigationView);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        // detail for android 5 devices
        getWindow().setStatusBarColor(ContextCompat.getColor(this, R.color.darkTitle));
    }

    //        new ShellExecuter().RunAsRootOutput("/system/bin/bootkali");
    // now pop in the default fragment

    getSupportFragmentManager().beginTransaction()
            .replace(R.id.container, NetHunterFragment.newInstance(R.id.nethunter_item)).commit();

    // and put the title in the queue for when you need to back through them
    titles.push(navigationView.getMenu().getItem(0).getTitle().toString());
    // if the nav bar hasn't been seen, let's show it
    if (!prefs.getBoolean("seenNav", false)) {
        mDrawerLayout.openDrawer(GravityCompat.START);
        SharedPreferences.Editor ed = prefs.edit();
        ed.putBoolean("seenNav", true);
        ed.commit();
    }

    if (lastSelected == null) { // only in the 1st create
        lastSelected = navigationView.getMenu().getItem(0);
        lastSelected.setChecked(true);
    }
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_opened,
            R.string.drawer_closed);
    mDrawerLayout.setDrawerListener(mDrawerToggle);

    mDrawerLayout.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
                setDrawerOptions();
            }
        }
    });
    mDrawerToggle.syncState();
    // pre-set the drawer options
    setDrawerOptions();

}

From source file:org.ounl.lifelonglearninghub.fcube.navigate.SwipeFragmentActivity.java

/**
 * On click one radiobutton, deslect the rest of the radiobuttons
 * /*from w ww . j  a v a2  s  .co m*/
 * @param v
 */
public void onSelectRadioButton(View v) {

    LinearLayout llRadioButton = (LinearLayout) v.getParent();
    LinearLayout llBranch = (LinearLayout) llRadioButton.getParent();
    LinearLayout llRoot = (LinearLayout) llBranch.getParent();

    RadioButton rbF = (RadioButton) llRoot.findViewById(R.id.rbFade);
    RadioButton rbRainbow = (RadioButton) llRoot.findViewById(R.id.rbRainbow);
    RadioButton rbRainbowC = (RadioButton) llRoot.findViewById(R.id.rbRainbowCircle);

    String sTag = v.getTag().toString();
    if (getString(R.string.rb_fade).compareTo(sTag) == 0) {

        rbRainbow.setChecked(false);
        rbRainbowC.setChecked(false);

    } else if (getString(R.string.rb_rainbow).compareTo(sTag) == 0) {

        rbF.setChecked(false);
        rbRainbowC.setChecked(false);

    } else if (getString(R.string.rb_rainbow_circle).compareTo(sTag) == 0) {

        rbF.setChecked(false);
        rbRainbow.setChecked(false);

    }

}

From source file:me.trashout.fragment.CollectionPointDetailFragment.java

/**
 * setup collection point data//from   w w  w.ja  v  a2  s.c  o  m
 *
 * @param collectionPoint
 */
private void setupCollectionPointData(CollectionPoint collectionPoint) {
    if (isAdded()) {
        collectionPointDetailName
                .setText(collectionPoint.getSize().equals(Constants.CollectionPointSize.DUSTBIN)
                        ? getString(Constants.CollectionPointSize.DUSTBIN.getStringResId())
                        : collectionPoint.getName());

        collectionPointDetailType.setText(Html.fromHtml(
                getString(R.string.recyclable_gray, getString(R.string.collectionPoint_detail_mobile_recycable))
                        + TextUtils.join(", ", Constants.CollectionPointType
                                .getCollectionPointTypeNameList(getContext(), collectionPoint.getTypes()))));
        collectionPointDetailDistance
                .setText(String.format(getString(R.string.distance_away_formatter),
                        lastPosition != null ? PositionUtils.getFormattedComputeDistance(getContext(),
                                lastPosition, collectionPoint.getPosition()) : "?",
                        getString(R.string.global_distanceAttribute_away)));
        collectionPointDetailPosition
                .setText(collectionPoint.getPosition() != null
                        ? PositionUtils.getFormattedLocation(getContext(),
                                collectionPoint.getPosition().latitude, collectionPoint.getPosition().longitude)
                        : "?");

        if (collectionPoint.getOpeningHours() == null || collectionPoint.getOpeningHours().isEmpty()) {
            collectionPointDetailOpeningHoursContainer.setVisibility(View.GONE);
            collectionPointDetailOpeningHours.setVisibility(View.GONE);
        } else {
            collectionPointDetailOpeningHoursContainer.setVisibility(View.VISIBLE);
            collectionPointDetailOpeningHoursContainer.removeAllViews();
            collectionPointDetailOpeningHours.setVisibility(View.VISIBLE);
            for (Map<String, List<OpeningHour>> openingHoursMap : collectionPoint.getOpeningHours()) {
                for (Map.Entry<String, List<OpeningHour>> openingHourEntry : openingHoursMap.entrySet()) {
                    LinearLayout openingHoursLayout = (LinearLayout) getLayoutInflater()
                            .inflate(R.layout.item_opening_hours, null);
                    TextView dayNameTextView = openingHoursLayout.findViewById(R.id.txt_day_name);
                    TextView openingHoursTextView = openingHoursLayout.findViewById(R.id.txt_opening_hours);

                    int dayNameResId;
                    switch (openingHourEntry.getKey()) {
                    case "Monday":
                        dayNameResId = R.string.global_days_Monday;
                        break;
                    case "Tuesday":
                        dayNameResId = R.string.global_days_Tuesday;
                        break;
                    case "Wednesday":
                        dayNameResId = R.string.global_days_Wednesday;
                        break;
                    case "Thursday":
                        dayNameResId = R.string.global_days_Thursday;
                        break;
                    case "Friday":
                        dayNameResId = R.string.global_days_Friday;
                        break;
                    case "Saturday":
                        dayNameResId = R.string.global_days_Saturday;
                        break;
                    case "Sunday":
                        dayNameResId = R.string.global_days_Sunday;
                        break;
                    default:
                        dayNameResId = R.string.global_days_Monday;
                    }

                    dayNameTextView.setText(getString(dayNameResId));
                    for (OpeningHour openingHour : openingHourEntry.getValue()) {
                        String startString = String.valueOf(openingHour.getStart());
                        String finishString = String.valueOf(openingHour.getFinish());
                        if (startString.length() == 3) {
                            startString = "0" + startString;
                        }
                        if (finishString.length() == 3) {
                            finishString = "0" + finishString;
                        }
                        openingHoursTextView.append(startString.substring(0, 2) + ":"
                                + startString.substring(2, startString.length()) + " - "
                                + finishString.substring(0, 2) + ":"
                                + finishString.substring(2, finishString.length()) + ", ");
                    }
                    if (openingHourEntry.getValue().size() > 0) {
                        openingHoursTextView.setText(openingHoursTextView.getText().toString().substring(0,
                                openingHoursTextView.getText().length() - 2));
                    }
                    collectionPointDetailOpeningHoursContainer.addView(openingHoursLayout);
                }
            }
        }
        collectionPointDetailNote.setText(collectionPoint.getNote());

        if (collectionPoint.getPhone() == null || collectionPoint.getPhone().isEmpty()) {
            collectionPointDetailPhoneLayout.setVisibility(View.GONE);
        } else {
            collectionPointDetailPhoneLayout.setVisibility(View.VISIBLE);
            collectionPointDetailPhone.setText(collectionPoint.getPhone());
        }
        if (collectionPoint.getEmail() == null || collectionPoint.getEmail().isEmpty()) {
            collectionPointDetailEmailLayout.setVisibility(View.GONE);
        } else {
            collectionPointDetailEmailLayout.setVisibility(View.VISIBLE);
            collectionPointDetailEmail.setText(collectionPoint.getEmail());
        }

        if (collectionPoint.getGps() != null && collectionPoint.getGps().getArea() != null
                && !TextUtils.isEmpty(collectionPoint.getGps().getArea().getFormatedLocation())) {
            collectionPointDetailPlace.setText(collectionPoint.getGps().getArea().getFormatedLocation());
        } else {
            Geocoder geocoder = new Geocoder(getActivity(), Locale.getDefault());
            new GeocoderTask(geocoder, collectionPoint.getGps().getLat(), collectionPoint.getGps().getLng(),
                    new GeocoderTask.Callback() {
                        @Override
                        public void onAddressComplete(GeocoderTask.GeocoderResult geocoderResult) {
                            if (!TextUtils.isEmpty(geocoderResult.getFormattedAddress())) {
                                collectionPointDetailPlace.setText(geocoderResult.getFormattedAddress());
                            } else {
                                collectionPointDetailPlace.setVisibility(View.GONE);
                            }
                        }
                    }).execute();
        }
    }
}

From source file:org.ale.scanner.zotero.EditItemActivity.java

private void extractValues() throws JSONException {
    JSONObject info = mWorkingItem.getSelectedInfo();

    LinearLayout container = ((LinearLayout) findViewById(R.id.editContainer));
    LinearLayout row;
    LinearLayout crow;/* www.j a  v  a  2  s . c  o m*/
    for (int i = 0; i < container.getChildCount(); i++) {
        row = (LinearLayout) container.getChildAt(i);

        switch (row.getId()) {
        case R.id.edit_field:
            TextView tv = (TextView) row.findViewById(R.id.label);
            EditText et = (EditText) row.findViewById(R.id.content);
            String label = (String) tv.getTag();
            String content = et.getText().toString();
            info.put(label, content);
            break;

        case R.id.edit_creators:
            JSONArray creators = new JSONArray();
            JSONObject creator;
            for (int c = 0; c < row.getChildCount(); c++) {
                crow = (LinearLayout) row.getChildAt(c);
                EditText name = (EditText) crow.findViewById(R.id.creator);
                if (TextUtils.isEmpty(name.getText().toString())) {
                    continue;
                }
                Spinner sp = (Spinner) crow.findViewById(R.id.creator_type);
                creator = new JSONObject();
                int indx = CreatorType.LocalizedBook.indexOf((String) sp.getSelectedItem());
                creator.put(CreatorType.type, CreatorType.Book.get(indx));
                creator.put(ItemField.Creator.name, name.getText().toString());
                creators.put(creator);
            }
            info.put(ItemField.creators, creators);
            break;

        case R.id.edit_notes:
            JSONArray notes = new JSONArray();
            JSONObject note;
            EditText note_et;
            for (int c = 0; c < row.getChildCount(); c++) {
                crow = (LinearLayout) row.getChildAt(c);
                note_et = (EditText) crow.findViewById(R.id.content);
                String note_content = note_et.getText().toString();
                if (TextUtils.isEmpty(note_content))
                    continue;

                note = new JSONObject();
                note.put(ItemField.Note.itemType, ItemField.Note.note);
                note.put(ItemField.Note.note, note_content);
                notes.put(note);
            }
            info.put(ItemField.notes, notes);
            break;

        case R.id.edit_tags:
            JSONArray tags = new JSONArray();
            JSONObject tag;
            EditText tag_et;
            for (int c = 0; c < row.getChildCount(); c++) {
                crow = (LinearLayout) row.getChildAt(c);
                tag_et = (EditText) crow.findViewById(R.id.content);
                String tag_content = tag_et.getText().toString();
                if (TextUtils.isEmpty(tag_content))
                    continue;

                tag = new JSONObject();
                tag.put(ItemField.Tag.tag, tag_content);
                tags.put(tag);
            }
            info.put(ItemField.tags, tags);
            break;

        default:
            break;
        }
    }
}

From source file:com.ehret.mixit.fragment.SessionDetailFragment.java

private void addSpeakerInfo(Talk conference) {
    //On vide les lments
    sessionPersonList.removeAllViews();/* ww w .  j av  a2s  .c o  m*/

    List<Member> speakers = new ArrayList<>();
    for (Speaker member : conference.getSpeakers()) {
        Member membre = MembreFacade.getInstance().getMembre(getActivity(), TypeFile.speaker.name(),
                member.getIdMember());

        if (membre != null) {
            speakers.add(membre);
        }
    }

    //On affiche les liens que si on a recuperer des choses
    if (!speakers.isEmpty()) {
        //On utilisait auparavant une liste pour afficher ces lments dans la page mais cette liste
        //empche d'avoir un ScrollView englobant pour toute la page. Nous utilisons donc un tableau

        //On ajoute un table layout
        TableLayout.LayoutParams tableParams = new TableLayout.LayoutParams(
                TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT);
        TableLayout tableLayout = new TableLayout(getActivity().getBaseContext());
        tableLayout.setLayoutParams(tableParams);

        if (mInflater != null) {
            for (final Member membre : speakers) {
                LinearLayout row = (LinearLayout) mInflater.inflate(R.layout.item_person, tableLayout, false);
                row.setBackgroundResource(R.drawable.row_transparent_background);

                //Dans lequel nous allons ajouter le contenu que nous faisons mapp dans
                TextView userName = (TextView) row.findViewById(R.id.person_user_name);
                TextView descriptif = (TextView) row.findViewById(R.id.person_shortdesciptif);
                TextView level = (TextView) row.findViewById(R.id.person_level);
                ImageView profileImage = (ImageView) row.findViewById(R.id.person_user_image);

                userName.setText(membre.getCompleteName());

                if (membre.getShortDescription() != null) {
                    descriptif.setText(membre.getShortDescription().trim());
                }

                //Recuperation de l'mage liee au profil
                Bitmap image = FileUtils.getImageProfile(getActivity(), membre);
                if (image == null) {
                    profileImage.setImageDrawable(getResources().getDrawable(R.drawable.person_image_empty));
                } else {
                    //On regarde dans les images embarquees
                    profileImage.setImageBitmap(image);
                }

                row.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        ((HomeActivity) getActivity()).changeCurrentFragment(PeopleDetailFragment
                                .newInstance(TypeFile.speaker.toString(), membre.getLogin(), 7),
                                TypeFile.speaker.toString());
                    }
                });

                tableLayout.addView(row);
            }
        }
        sessionPersonList.addView(tableLayout);
    }
}

From source file:org.nla.tarotdroid.lib.ui.GameSetSynthesisFragment.java

/**
  * Refreshes the stats rows on the synthesis view.
  *//*from  ww  w.j  a v a 2s.c o  m*/
protected void refreshPlayerStatsRows() {
    // sort players
    List<Player> sortedPlayers = this.getGameSet().getPlayers().getPlayers();
    Collections.sort(sortedPlayers, new PlayerScoreComparator());

    // get general data sources
    IGameSetStatisticsComputer gameSetStatisticsComputer = GameSetStatisticsComputerFactory
            .GetGameSetStatisticsComputer(this.getGameSet(), "guava");
    MapPlayersScores lastScores = this.getGameSet().getGameSetScores().getResultsAtLastGame();
    Map<Player, Integer> leadingCount = gameSetStatisticsComputer.getLeadingCount();
    Map<Player, Integer> leadingSuccesses = gameSetStatisticsComputer.getLeadingSuccessCount();
    Map<Player, Integer> calledCount = gameSetStatisticsComputer.getCalledCount();
    int minScoreEver = gameSetStatisticsComputer.getMinScoreEver();
    int maxScoreEver = gameSetStatisticsComputer.getMaxScoreEver();

    // format statistics lines
    for (int rank = 0; rank < sortedPlayers.size(); ++rank) {
        // get player specific data sources
        Player player = sortedPlayers.get(rank);
        int lastScore = lastScores == null ? 0 : lastScores.get(player);
        int successfulLeadingGamesCount = leadingSuccesses.get(player) == null ? 0
                : leadingSuccesses.get(player).intValue();
        int leadingGamesCount = leadingCount.get(player) == null ? 0 : leadingCount.get(player);
        int successRate = (int) (((double) successfulLeadingGamesCount) / ((double) leadingGamesCount) * 100.0);
        int minScoreForPlayer = gameSetStatisticsComputer.getMinScoreEverForPlayer(player);
        int maxScoreForPlayer = gameSetStatisticsComputer.getMaxScoreEverForPlayer(player);

        // get line widgets
        LinearLayout statRow = this.statsRows.get(rank + 1);
        //TextView statPlayerName = (TextView)statRow.findViewById(R.id.statPlayerName);
        TextView statScore = (TextView) statRow.findViewById(R.id.statScore);
        TextView statLeadingGamesCount = (TextView) statRow.findViewById(R.id.statLeadingGamesCount);
        TextView statSuccessfulGamesCount = (TextView) statRow.findViewById(R.id.statSuccessfulGamesCount);
        TextView statMinScore = (TextView) statRow.findViewById(R.id.statMinScore);
        TextView statMaxScore = (TextView) statRow.findViewById(R.id.statMaxScore);

        //          Bitmap playerImage = null;
        //          if (player.getPictureUri() != null && !player.getPictureUri().equals("")) {
        //             playerImage = UIHelper.getPlayerImage(this.getActivity(), player);
        //          }
        //          
        //            
        //            // assign values to widgets
        //            if (player.getFacebookId() != null) {
        //             // player facebook image
        //             ProfilePictureView pictureView = new ProfilePictureView(this.getActivity());
        //             pictureView.setProfileId(player.getFacebookId());
        //             pictureView.setPresetSize(ProfilePictureView.SMALL);
        //             //pictureView.setOnClickListener(playerClickListener);
        //             pictureView.setLayoutParams(UIConstants.PLAYERS_LAYOUT_PARAMS);
        //             statRow.removeViewAt(0);
        //               statRow.addView(pictureView, 0);
        //            }
        //            else {
        //               // WARNING: The properties below reference the style ScoreTextStyle, but we can't set a style at runtime.
        //               TextView playerName = new TextView(this.getActivity());
        //               playerName.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, 1));
        //               playerName.setGravity(Gravity.CENTER);
        //               playerName.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
        //               playerName.setEllipsize(TruncateAt.END);
        //               playerName.setSingleLine();
        //               playerName.setTextColor(Color.WHITE);
        //               playerName.setTypeface(null, Typeface.BOLD);
        //               playerName.setText(player.getName());
        //               //playerName.setBackgroundResource(R.drawable.border_player_white);
        //               statRow.removeViewAt(0);
        //               statRow.addView(playerName, 0);
        //            }

        OnClickListener playerClickListener = new PlayerClickListener(player);

        // facebook picture
        if (player.getFacebookId() != null) {
            ProfilePictureView pictureView = new ProfilePictureView(this.getActivity());
            pictureView.setProfileId(player.getFacebookId());
            pictureView.setPresetSize(ProfilePictureView.SMALL);
            pictureView.setLayoutParams(UIConstants.PLAYERS_LAYOUT_PARAMS);

            pictureView.setOnClickListener(playerClickListener);
            //this.addView(pictureView);
            statRow.removeViewAt(0);
            statRow.addView(pictureView, 0);
        }

        // contact picture
        else if (player.getPictureUri() != null
                && player.getPictureUri().toString().contains("content://com.android.contacts/contacts")) {
            Bitmap playerImage = UIHelper.getContactPicture(this.getActivity(),
                    Uri.parse(player.getPictureUri()).getLastPathSegment());
            ImageView imgPlayer = new ImageView(this.getActivity());
            imgPlayer.setImageBitmap(playerImage);
            imgPlayer.setLayoutParams(UIConstants.PLAYERS_LAYOUT_PARAMS);

            imgPlayer.setOnClickListener(playerClickListener);
            //this.addView(imgPlayer);
            statRow.removeViewAt(0);
            statRow.addView(imgPlayer, 0);
        }

        // no picture, only name
        else {
            TextView txtPlayer = new TextView(this.getActivity());
            txtPlayer.setText(player.getName());
            txtPlayer.setGravity(Gravity.CENTER);
            txtPlayer.setLayoutParams(UIConstants.PLAYERS_LAYOUT_PARAMS);
            txtPlayer.setMinWidth(UIConstants.PLAYER_VIEW_WIDTH);
            txtPlayer.setHeight(UIConstants.PLAYER_VIEW_HEIGHT);
            txtPlayer.setBackgroundColor(Color.TRANSPARENT);
            txtPlayer.setTypeface(null, Typeface.BOLD);
            txtPlayer.setTextColor(Color.WHITE);
            txtPlayer.setSingleLine();
            txtPlayer.setEllipsize(TruncateAt.END);

            txtPlayer.setOnClickListener(playerClickListener);
            //this.addView(txtPlayer);
            statRow.removeViewAt(0);
            statRow.addView(txtPlayer, 0);
        }

        statScore.setText(Integer.toString(lastScore));
        statLeadingGamesCount.setText(Integer.toString(leadingGamesCount));
        statSuccessfulGamesCount.setText(
                Integer.toString(successfulLeadingGamesCount) + " (" + Integer.toString(successRate) + "%)");

        // display called game count if necessary 
        if (this.getGameSet().getGameStyleType() == GameStyleType.Tarot5) {
            TextView statCalledGamesCount = (TextView) statRow.findViewById(R.id.statCalledGamesCount);
            statCalledGamesCount
                    .setText(Integer.toString(calledCount.get(player) == null ? 0 : calledCount.get(player)));
        }

        statMinScore.setText(Integer.toString(minScoreForPlayer));
        statMaxScore.setText(Integer.toString(maxScoreForPlayer));
        statMinScore.setTextColor(Color.WHITE);
        statMaxScore.setTextColor(Color.WHITE);

        // color min score if lowest
        if (minScoreEver == minScoreForPlayer) {
            statMinScore.setTextColor(Color.YELLOW);
        }

        // color max score if highest
        if (maxScoreEver == maxScoreForPlayer) {
            statMaxScore.setTextColor(Color.GREEN);
        }
    }
}

From source file:com.netease.nim.chatroom.demo.im.ui.tab.PagerSlidingTabStrip.java

public void updateTab(int index, ReminderItem item) {
    LinearLayout tabView = (LinearLayout) tabsContainer.getChildAt(index);
    ImageView indicatorView = (ImageView) tabView.findViewById(R.id.tab_new_indicator);

    if (item == null || indicatorView == null) {
        return;//from   w  w  w  .  j av  a  2  s.c om
    }
    boolean indicator = item.indicator();
    indicatorView.setVisibility(indicator ? View.VISIBLE : View.GONE);
}

From source file:de.grobox.liberario.TripsActivity.java

private void addTrips(final TableLayout main, List<Trip> trip_list, boolean append) {
    if (trip_list != null) {
        // reverse order of trips if they should be prepended
        if (!append) {
            ArrayList<Trip> tempResults = new ArrayList<Trip>(trip_list);
            Collections.reverse(tempResults);
            trip_list = tempResults;// www .j  a va2 s .c o  m
        }

        for (final Trip trip : trip_list) {
            final LinearLayout trip_layout = (LinearLayout) LayoutInflater.from(this).inflate(R.layout.trip,
                    null);
            TableRow row = (TableRow) trip_layout.findViewById(R.id.tripTableRow);

            // Locations
            TextView fromView = (TextView) row.findViewById(R.id.fromView);
            fromView.setText(trip.from.uniqueShortName());
            TextView toView = ((TextView) row.findViewById(R.id.toView));
            toView.setText(trip.to.uniqueShortName());

            // Departure Time and Delay
            TextView departureTimeView = (TextView) row.findViewById(R.id.departureTimeView);
            TextView departureDelayView = (TextView) row.findViewById(R.id.departureDelayView);
            if (trip.getFirstPublicLeg() != null) {
                LiberarioUtils.setDepartureTimes(this, departureTimeView, departureDelayView,
                        trip.getFirstPublicLeg().departureStop);
            } else {
                departureTimeView.setText(DateUtils.getTime(this, trip.getFirstDepartureTime()));
            }

            // Arrival Time and Delay
            TextView arrivalTimeView = (TextView) row.findViewById(R.id.arrivalTimeView);
            TextView arrivalDelayView = (TextView) row.findViewById(R.id.arrivalDelayView);
            if (trip.getLastPublicLeg() != null) {
                LiberarioUtils.setArrivalTimes(this, arrivalTimeView, arrivalDelayView,
                        trip.getLastPublicLeg().arrivalStop);
            } else {
                arrivalTimeView.setText(DateUtils.getTime(this, trip.getLastArrivalTime()));
            }

            // Duration
            TextView durationView = (TextView) trip_layout.findViewById(R.id.durationView);
            durationView
                    .setText(DateUtils.getDuration(trip.getFirstDepartureTime(), trip.getLastArrivalTime()));

            // Transports
            FlowLayout lineLayout = (FlowLayout) trip_layout.findViewById(R.id.lineLayout);

            // for each leg
            for (final Leg leg : trip.legs) {
                if (leg instanceof Trip.Public) {
                    LiberarioUtils.addLineBox(this, lineLayout, ((Public) leg).line);
                } else if (leg instanceof Trip.Individual) {
                    LiberarioUtils.addWalkingBox(this, lineLayout);
                }
            }

            // remember trip in view for onClick event
            trip_layout.setTag(trip);

            // make trip details fold out and in on click
            trip_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    View v = main.getChildAt(main.indexOfChild(view) + 1);

                    if (v != null) {
                        if (v.getVisibility() == View.GONE) {
                            v.setVisibility(View.VISIBLE);
                        } else if (v.getVisibility() == View.VISIBLE) {
                            v.setVisibility(View.GONE);
                        }
                    }
                }

            });
            trip_layout.setOnLongClickListener(new View.OnLongClickListener() {
                @Override
                public boolean onLongClick(View view) {
                    selectTrip(view, trip_layout);
                    return true;
                }
            });

            // show more button for trip details
            final ImageView showMoreView = (ImageView) trip_layout.findViewById(R.id.showMoreView);
            showMoreView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    selectTrip(view, trip_layout);
                }
            });

            // Create container for trip details fragment
            FrameLayout fragmentContainer = new FrameLayout(this);
            fragmentContainer.setId(mContainerId);
            fragmentContainer.setVisibility(View.GONE);

            // Create a new Fragment to be placed in the activity layout
            TripDetailFragment tripDetailFragment = new TripDetailFragment();

            // In case this activity was started with special instructions from an
            // Intent, pass the Intent's extras to the fragment as arguments
            Bundle bundle = new Bundle();
            bundle.putSerializable("de.schildbach.pte.dto.Trip", trip);
            bundle.putSerializable("de.schildbach.pte.dto.Trip.from", from);
            bundle.putSerializable("de.schildbach.pte.dto.Trip.to", to);
            tripDetailFragment.setArguments(bundle);

            // Add the fragment to the 'fragment_container' FrameLayout
            getSupportFragmentManager().beginTransaction().add(mContainerId, tripDetailFragment).commit();

            mContainerId++;

            if (append) {
                trip_layout.addView(LiberarioUtils.getDivider(this));
                main.addView(trip_layout);
                main.addView(fragmentContainer);
            } else {
                trip_layout.addView(LiberarioUtils.getDivider(this), 0);
                main.addView(trip_layout, 0);
                main.addView(fragmentContainer, 1);
            }
        } // end foreach trip

    } else {
        // TODO offer option to query again for trips
    }
}