Example usage for android.widget LinearLayout getChildAt

List of usage examples for android.widget LinearLayout getChildAt

Introduction

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

Prototype

public View getChildAt(int index) 

Source Link

Document

Returns the view at the specified position in the group.

Usage

From source file:com.mobicage.rogerthat.plugins.messaging.ServiceMessageDetailActivity.java

private void addButton(final String senderName, String myEmail, boolean somebodyAnswered, boolean canEdit,
        TableLayout tableLayout, final ButtonTO button) {
    TableRow row = new TableRow(this);
    tableLayout.addView(row);/*  w  w  w.jav  a2s .  c  o  m*/
    row.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT,
            TableLayout.LayoutParams.WRAP_CONTENT, 1));

    // XXX: inconsistent margin between 2 rows

    final Button buttonView = new Button(this);
    buttonView.setMinWidth(UIUtils.convertDipToPixels(this, 100));
    buttonView.setText(button.caption);
    buttonView.setTextColor(getResources().getColor(android.R.color.primary_text_dark));
    if (somebodyAnswered)
        buttonView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
    else {
        buttonView.setWidth(mDisplayWidth - UIUtils.convertDipToPixels(this, 12));
    }
    buttonView.setTextSize(19);
    row.addView(buttonView);

    final LinearLayout container = (LinearLayout) getLayoutInflater().inflate(R.layout.message_button_detail,
            null);
    container.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);

    boolean buttonSelectedByMe = false;
    for (MemberStatusTO status : mCurrentMessage.members) {
        if ((status.status & MessagingPlugin.STATUS_ACKED) == MessagingPlugin.STATUS_ACKED
                && ((button.id == null && status.button_id == null)
                        || (button.id != null && button.id.equals(status.button_id)))) {

            getLayoutInflater().inflate(R.layout.avatar, container);
            ImageView avatar = (ImageView) container.getChildAt(container.getChildCount() - 1);

            setAvatar(avatar, status.member);
            if (status.member.equals(myEmail))
                buttonSelectedByMe = true;

            int dp42 = UIUtils.convertDipToPixels(this, 42);
            int dp2 = UIUtils.convertDipToPixels(this, 1);
            LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) avatar.getLayoutParams();
            lp.setMargins(0, dp2, 0, 0);
            lp.width = dp42;
            lp.height = dp42;
        }
    }

    row.addView(container);

    boolean hasAction = button.action != null && !"".equals(button.action);
    final boolean buttonIsEnabled = canEdit
            && (mCurrentMessage.form != null || !buttonSelectedByMe || hasAction);
    buttonView.setEnabled(buttonIsEnabled);

    int color;
    if (button.id == null || mCurrentMessage.form != null && Message.POSITIVE.equals(button.id)) {
        color = buttonIsEnabled ? Message.GREEN_BUTTON_COLOR : Message.GREENGRAY_BUTTON_COLOR;
    } else if (mCurrentMessage.form != null && Message.NEGATIVE.equals(button.id)) {
        color = buttonIsEnabled ? Message.RED_BUTTON_COLOR : Message.REDGRAY_BUTTON_COLOR;
    } else {
        color = buttonIsEnabled ? Message.BLUE_BUTTON_COLOR : Message.BLUEGRAY_BUTTON_COLOR;
    }
    buttonView.getBackground().setColorFilter(color, PorterDuff.Mode.MULTIPLY);

    buttonView.setOnClickListener(new SafeViewOnClickListener() {

        @Override
        public void safeOnClick(View v) {
            T.UI();
            executeButtonClick(button, container, true);
        }
    });

    final HorizontalScrollView scroller = (HorizontalScrollView) findViewById(R.id.button_scroller);
    scroller.post(new SafeRunnable() {
        @Override
        protected void safeRun() throws Exception {
            scroller.fullScroll(ScrollView.FOCUS_RIGHT);
        }
    });
}

From source file:com.google.samples.apps.iosched.ui.widget.CollectionView.java

private View createGroupView(RowComputeResult rowInfo, View view, ViewGroup parent) {
    ViewGroup groupView;//from  ww w.  j ava 2 s . c o m
    if (view != null && view instanceof ViewGroup) {
        groupView = (ViewGroup) view;
        // If there are more children in the recycled view we remove the extra ones.
        if (groupView.getChildAt(0) instanceof LinearLayout) {
            LinearLayout groupViewContent = (LinearLayout) groupView.getChildAt(0);
            if (groupViewContent.getChildCount() > rowInfo.group.getRowCount()) {
                groupViewContent.removeViews(rowInfo.group.getRowCount(),
                        groupViewContent.getChildCount() - rowInfo.group.getRowCount());
            }
        }
        // Use the defined callbacks if the user has chosen to by implementing a
        // CardsCollectionViewCallbacks.
    } else if (mCallbacks instanceof CollectionViewCallbacks.GroupCollectionViewCallbacks) {
        groupView = ((CollectionViewCallbacks.GroupCollectionViewCallbacks) mCallbacks)
                .newCollectionGroupView(getContext(), rowInfo.groupId, rowInfo.group, parent);
        // This should never happened but if it does we'll display an EmptyView.
    } else {
        LOGE(TAG, "Tried to create a group view but the callback is not an instance of "
                + "GroupCollectionViewCallbacks");
        return new EmptyView(getContext());
    }
    LinearLayout groupViewContent;
    if (groupView.getChildAt(0) instanceof LinearLayout) {
        groupViewContent = (LinearLayout) groupView.getChildAt(0);
    } else {
        groupViewContent = new LinearLayout(getContext());
        groupViewContent.setOrientation(LinearLayout.VERTICAL);
        LayoutParams LLParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        groupViewContent.setLayoutParams(LLParams);
        groupView.addView(groupViewContent);
    }
    disableCustomGroupView();
    for (int i = 0; i < rowInfo.group.getRowCount(); i++) {
        View itemView;
        try {
            itemView = getRowView(rowInfo.groupOffset + i, groupViewContent.getChildAt(i), groupViewContent);
        } catch (Exception e) {
            // Recycling failed (maybe the items were not compatible) so we start again without
            // recycling.
            itemView = getRowView(rowInfo.groupOffset + i, null, groupViewContent);
        }
        if (itemView != groupViewContent.getChildAt(i)) {
            if (groupViewContent.getChildCount() > i) {
                groupViewContent.removeViewAt(i);
            }
            groupViewContent.addView(itemView, i);
        }
    }
    enableCustomGroupView();
    return groupView;
}

From source file:com.razza.apps.iosched.ui.widget.CollectionView.java

private View createGroupView(RowComputeResult rowInfo, View view, ViewGroup parent) {
    ViewGroup groupView;//from w  w w.  j a  va2 s .c  o  m
    if (view != null && view instanceof ViewGroup) {
        groupView = (ViewGroup) view;
        // If there are more children in the recycled view we remove the extra ones.
        if (groupView.getChildAt(0) instanceof LinearLayout) {
            LinearLayout groupViewContent = (LinearLayout) groupView.getChildAt(0);
            if (groupViewContent.getChildCount() > rowInfo.group.getRowCount()) {
                groupViewContent.removeViews(rowInfo.group.getRowCount(),
                        groupViewContent.getChildCount() - rowInfo.group.getRowCount());
            }
        }
        // Use the defined callbacks if the user has chosen to by implementing a
        // CardsCollectionViewCallbacks.
    } else if (mCallbacks instanceof CollectionViewCallbacks.GroupCollectionViewCallbacks) {
        groupView = ((CollectionViewCallbacks.GroupCollectionViewCallbacks) mCallbacks)
                .newCollectionGroupView(getContext(), rowInfo.groupId, rowInfo.group, parent);
        // This should never happened but if it does we'll display an EmptyView.
    } else {
        LogUtils.LOGE(TAG, "Tried to create a group view but the callback is not an instance of "
                + "GroupCollectionViewCallbacks");
        return new EmptyView(getContext());
    }
    LinearLayout groupViewContent;
    if (groupView.getChildAt(0) instanceof LinearLayout) {
        groupViewContent = (LinearLayout) groupView.getChildAt(0);
    } else {
        groupViewContent = new LinearLayout(getContext());
        groupViewContent.setOrientation(LinearLayout.VERTICAL);
        LayoutParams LLParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        groupViewContent.setLayoutParams(LLParams);
        groupView.addView(groupViewContent);
    }
    disableCustomGroupView();
    for (int i = 0; i < rowInfo.group.getRowCount(); i++) {
        View itemView;
        try {
            itemView = getRowView(rowInfo.groupOffset + i, groupViewContent.getChildAt(i), groupViewContent);
        } catch (Exception e) {
            // Recycling failed (maybe the items were not compatible) so we start again without
            // recycling.
            itemView = getRowView(rowInfo.groupOffset + i, null, groupViewContent);
        }
        if (itemView != groupViewContent.getChildAt(i)) {
            if (groupViewContent.getChildCount() > i) {
                groupViewContent.removeViewAt(i);
            }
            groupViewContent.addView(itemView, i);
        }
    }
    enableCustomGroupView();
    return groupView;
}

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

/**
 * Helper method which refreshes the module layout between module downloads/deletions.
 *///from   w ww .  j  a va 2s  .  c  o m
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:com.heath_bar.tvdb.SeriesOverview.java

protected void ShowHideEpisodes(View seasonRow) {

    // Get the linear layout that we will be adding/removing the episodes to/from
    LinearLayout epLinearLayout = (LinearLayout) seasonRow;

    if (epLinearLayout.getChildCount() == 1) { // if collapsed, expand (add) the seasons

        TextView seasonText = (TextView) seasonRow.findViewById(R.id.season_text);
        seasonText.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable.arrow_down),
                null, null, null);//from www  .  jav a 2 s  . c  om

        LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        for (int i = 0; i < episodeList.size(); i++) {
            if (seasonRow.getId() == episodeList.get(i).getSeason()) {
                View episodeView = inflater.inflate(R.layout.episode_text_row, epLinearLayout, false);

                episodeView.setBackgroundColor(
                        AppSettings.listBackgroundColors[i % AppSettings.listBackgroundColors.length]);

                TextView text = (TextView) episodeView.findViewById(R.id.text);
                String nameText = String.format("%02d", episodeList.get(i).getNumber()) + " "
                        + episodeList.get(i).getName();
                text.setText(nameText);
                text.setTextSize(textSize);
                text.setId(episodeList.get(i).getId());

                episodeView.setOnClickListener(episodeListener);
                epLinearLayout.addView(episodeView);
            }
        }
    } else { // else season is expanded, collapse it
        TextView seasonText = (TextView) seasonRow.findViewById(R.id.season_text);
        seasonText.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable.arrow_right),
                null, null, null);

        for (int i = epLinearLayout.getChildCount() - 1; i > 0; i--) {
            epLinearLayout.removeView(epLinearLayout.getChildAt(i));
        }

    }

}

From source file:foam.starwisp.StarwispBuilder.java

public String WalkDraggable(StarwispActivity ctx, String name, String ctxname, int id) {
    View v = ctx.findViewById(id);
    Class c = v.getClass();//from  w  ww  .  ja va  2 s  .co  m
    String ret = "";
    if (c == LinearLayout.class) {
        LinearLayout l = (LinearLayout) v;
        String result = m_Scheme.eval("(run-draggable-callback \"" + ctxname + "\" " + id + " '())") + " ";
        try {
            JSONArray arr = new JSONArray(result);

            int is_atom = arr.getInt(0);
            if (is_atom == 0)
                ret += "(";

            // a number?
            if (is_atom == 2)
                ret += arr.getString(1) + " ";
            else
                ret += JSONToScheme(arr.getString(1)) + " ";

            //Log.i("starwisp","post conv "+ret);

            for (int i = 0; i < l.getChildCount(); i++) {
                View cv = l.getChildAt(i);
                Class cc = cv.getClass();
                if (cc == LinearLayout.class) {
                    ret += WalkDraggable(ctx, name, ctxname, cv.getId());
                }
            }
            if (is_atom == 0)
                ret += ")";
        } catch (JSONException e) {
            Log.e("starwisp", "Error parsing draggable code " + e.toString());
            Log.e("starwisp", "Code is: " + ret);
            return "";
        }
    }
    return ret;
}

From source file:reportsas.com.formulapp.Formulario.java

public int ObtenerRespuesta(LinearLayout contenedor, Pregunta Pregunta,
        ArrayList<PreguntaRespuesta> respuestaList) {
    PreguntaRespuesta result = new PreguntaRespuesta();
    int numRespuesta = 0;
    result.setIdPregunta(Pregunta.getIdPregunta());
    EditText resp;/*from  www .  j  av  a2s. c  o m*/
    TextView selectio;
    switch (Pregunta.getTipoPregunta()) {
    case 1:
        resp = (EditText) contenedor.findViewById(R.id.edtTexto);
        result.setItem(1);
        result.setRespuesta(resp.getText().toString());
        respuestaList.add(result);
        numRespuesta = 1;
        break;
    case 2:
        resp = (EditText) contenedor.findViewById(R.id.mtxtEdit);
        result.setItem(1);
        result.setRespuesta(resp.getText().toString());
        respuestaList.add(result);
        numRespuesta = 1;
        break;
    case 3:
        selectio = (TextView) contenedor.findViewById(R.id.respuestaGruop);
        result.setItem(1);
        result.setRespuesta(selectio.getText().toString());
        respuestaList.add(result);
        numRespuesta = 1;
        break;
    case 4:

        String resp_opcio = "";
        for (int j = 0; j < contenedor.getChildCount(); j++) {
            View child = contenedor.getChildAt(j);
            if (child instanceof CheckBox) {
                CheckBox hijo = (CheckBox) child;
                if (hijo.isChecked()) {
                    if (resp_opcio.length() == 0) {
                        if (Pregunta.isOpcionEditble(hijo.getText().toString())) {
                            EditText otrosR = (EditText) contenedor.findViewById(R.id.edtTexto);
                            resp_opcio = otrosR.getText().toString();
                        } else {
                            resp_opcio = hijo.getText().toString();
                        }
                    } else {
                        if (Pregunta.isOpcionEditble(hijo.getText().toString())) {
                            EditText otrosR = (EditText) contenedor.findViewById(R.id.edtTexto);
                            resp_opcio += " , " + otrosR.getText().toString() + " ";
                        } else {
                            resp_opcio = resp_opcio + " , " + hijo.getText() + " ";
                        }

                    }
                }
            }

        }
        result.setItem(1);
        result.setRespuesta(resp_opcio);
        respuestaList.add(result);
        numRespuesta = 1;
        break;
    case 5:
        selectio = (TextView) contenedor.findViewById(R.id.seleEscala);
        result.setItem(1);
        result.setRespuesta(selectio.getText().toString());
        respuestaList.add(result);
        numRespuesta = 1;
        break;
    case 6:
        Spinner lista = (Spinner) contenedor.findViewById(R.id.opcionesListado);
        result.setItem(1);
        result.setRespuesta(lista.getSelectedItem().toString() + "");
        respuestaList.add(result);
        numRespuesta = 1;
        break;
    case 7:
        TableLayout tabla = (TableLayout) contenedor.findViewById(R.id.tablaOpciones);
        for (int i = 0; i < tabla.getChildCount(); i++) {
            TableRow registro = (TableRow) tabla.getChildAt(i);
            TextView etiq = (TextView) registro.findViewById(R.id.textoRow);
            RadioGroup selector = (RadioGroup) registro.findViewById(R.id.valoresRow);
            PreguntaRespuesta itemA = new PreguntaRespuesta();
            itemA.setIdPregunta(Pregunta.getIdPregunta());
            itemA.setItem(i + 1);
            itemA.setRespuesta(etiq.getText().toString());
            if (selector.getCheckedRadioButtonId() > 0) {
                RadioButton rb = (RadioButton) selector.findViewById(selector.getCheckedRadioButtonId());
                itemA.setOpcion(rb.getText() + "");
            }

            respuestaList.add(itemA);
            numRespuesta++;
        }

        break;
    case 8:
        DatePicker dp = (DatePicker) contenedor.findViewById(R.id.Fecha_resutl);
        result.setItem(1);
        result.setRespuesta(dp.getYear() + "-" + dp.getMonth() + "-" + dp.getDayOfMonth());
        respuestaList.add(result);
        numRespuesta = 1;
        break;
    case 9:
        TimePicker tp = (TimePicker) contenedor.findViewById(R.id.hora_result);
        result.setItem(1);
        result.setRespuesta(tp.getCurrentHour() + ":" + tp.getCurrentMinute());
        respuestaList.add(result);
        numRespuesta = 1;
        break;

    default:
        result.setItem(1);
        result.setRespuesta("Proceso");
        break;

    }

    return numRespuesta;

}

From source file:com.mdlive.sav.MDLiveProviderDetails.java

private void phsOnlyForPhone() {
    saveAppmtType("phone");
    byvideoBtnLayout.setBackgroundResource(R.drawable.disable_round_rect_grey_border);
    byvideoBtn.setTextColor(getResources().getColor(R.color.disableBtn));
    ((ImageView) findViewById(R.id.videoicon)).setImageResource(R.drawable.video_icon_gray);
    byvideoBtnLayout.setVisibility(View.VISIBLE);
    byvideoBtnLayout.setClickable(false);
    byphoneBtnLayout.setVisibility(View.VISIBLE);
    byphoneBtnLayout.setOnClickListener(new View.OnClickListener() {
        @Override/*from   w ww .  j av  a2  s  . com*/
        public void onClick(View v) {
            try {
                horizontalscrollview.smoothScrollTo(layout.getChildAt(0).getLeft(), 0);
                byphoneBtnLayout.setBackgroundResource(R.drawable.searchpvr_blue_rounded_corner);
                byphoneBtn.setTextColor(Color.WHITE);
                ((ImageView) findViewById(R.id.phoneicon)).setImageResource(R.drawable.phone_icon_white);
                ((ImageView) findViewById(R.id.videoicon)).setImageResource(R.drawable.video_icon_gray);
                horizontalscrollview.setVisibility(View.VISIBLE);
                byvideoBtnLayout.setVisibility(View.VISIBLE);
                byvideoBtnLayout.setBackgroundResource(R.drawable.disable_round_rect_grey_border);
                byvideoBtn.setTextColor(getResources().getColor(R.color.disableBtn));
                byvideoBtnLayout.setClickable(false);

                LinearLayout layout = (LinearLayout) findViewById(R.id.panelMessageFiles);
                if (layout.getChildCount() > 0) {
                    layout.removeAllViews();
                }
                for (TextView tv : phoneList) {
                    layout.addView(tv);
                }
                saveConsultationType("Phone", MDLiveProviderDetails.this);
                //Enable Request Appointment Button
                enableReqAppmtBtn();
                horizontalscrollview.smoothScrollTo(layout.getChildAt(0).getLeft(), 0);
                ((ImageView) findViewById(R.id.phoneicon)).setImageResource(R.drawable.phone_icon_white);
                selectedTimeslot = false;
                enableReqAppmtBtn();
                clearTimeSlotViews();
                horizontalscrollview.startAnimation(
                        AnimationUtils.loadAnimation(MDLiveProviderDetails.this, R.anim.mdlive_trans_left_in));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}

From source file:com.mdlive.sav.MDLiveProviderDetails.java

private void onlyForIdaho() {
    byphoneBtnLayout.setVisibility(View.VISIBLE);
    byphoneBtnLayout.setBackgroundResource(R.drawable.disable_round_rect_grey_border);
    byphoneBtn.setTextColor(getResources().getColor(R.color.disableBtn));
    ((ImageView) findViewById(R.id.phoneicon)).setImageResource(R.drawable.phone_icon_gray);
    byphoneBtnLayout.setClickable(false);
    saveAppmtType("video");
    byvideoBtnLayout.setBackgroundResource(R.drawable.searchpvr_white_rounded_corner);
    byvideoBtn.setTextColor(Color.GRAY);
    byvideoBtn.setTextColor(Color.GRAY);
    byvideoBtnLayout.setVisibility(View.VISIBLE);
    byvideoBtnLayout.setOnClickListener(new View.OnClickListener() {
        @Override/*from  w ww.  ja v  a2 s.  c om*/
        public void onClick(View v) {
            try {
                horizontalscrollview.smoothScrollTo(layout.getChildAt(0).getLeft(), 0);
                byvideoBtnLayout.setBackgroundResource(R.drawable.searchpvr_blue_rounded_corner);
                byvideoBtn.setTextColor(Color.WHITE);
                ((ImageView) findViewById(R.id.videoicon)).setImageResource(R.drawable.video_icon_white);
                ((ImageView) findViewById(R.id.phoneicon)).setImageResource(R.drawable.phone_icon_gray);
                byphoneBtnLayout.setBackgroundResource(R.drawable.disable_round_rect_grey_border);
                byphoneBtn.setTextColor(getResources().getColor(R.color.disableBtn));
                byphoneBtnLayout.setVisibility(View.VISIBLE);
                byphoneBtnLayout.setClickable(false);

                horizontalscrollview.setVisibility(View.VISIBLE);
                LinearLayout layout = (LinearLayout) findViewById(R.id.panelMessageFiles);
                if (layout.getChildCount() > 0) {
                    layout.removeAllViews();
                }

                for (TextView tv : videoList) {
                    layout.addView(tv);
                }
                saveConsultationType("Video", MDLiveProviderDetails.this);
                //Enable Request Appointment Button

                horizontalscrollview.smoothScrollTo(layout.getChildAt(0).getLeft(), 0);
                ((ImageView) findViewById(R.id.videoicon)).setImageResource(R.drawable.video_icon_white);
                selectedTimeslot = false;
                enableReqAppmtBtn();
                clearTimeSlotViews();
                horizontalscrollview.startAnimation(
                        AnimationUtils.loadAnimation(MDLiveProviderDetails.this, R.anim.mdlive_trans_left_in));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}

From source file:info.tellmetime.DaydreamService.java

@Override
public void onAttachedToWindow() {
    super.onAttachedToWindow();

    setInteractive(true);//from  w  ww  . ja v  a  2  s.c  om

    setFullscreen(true);

    setContentView(R.layout.daydream);

    LinearLayout mClock = (LinearLayout) findViewById(R.id.clock);

    SharedPreferences settings = getSharedPreferences("PREFS", Context.MODE_PRIVATE);
    mHighlightColor = settings.getInt(TellmetimeActivity.HIGHLIGHT, Color.WHITE);
    mBacklightColor = settings.getInt(TellmetimeActivity.BACKLIGHT,
            getResources().getColor(R.color.backlight_light));
    mMinutesSize = settings.getInt(TellmetimeActivity.MINUTES_SIZE, 36);
    isNightMode = settings.getBoolean(TellmetimeActivity.NIGHTMODE, false);

    setScreenBright(!isNightMode);
    findViewById(R.id.overlay).setBackgroundColor(
            getResources().getColor(isNightMode ? R.color.night_mode_overlay : android.R.color.transparent));

    RelativeLayout mSurface = (RelativeLayout) findViewById(R.id.surface);
    mSurface.setBackgroundColor(
            settings.getInt(TellmetimeActivity.BACKGROUND, getResources().getColor(R.color.background)));
    switch (settings.getInt(TellmetimeActivity.BACKGROUND_MODE, TellmetimeActivity.MODE_BACKGROUND_SOLID)) {
    case TellmetimeActivity.MODE_BACKGROUND_WALLPAPER:
        ((ImageView) findViewById(R.id.background_image))
                .setImageDrawable(WallpaperManager.getInstance(this).getDrawable());
        break;

    case TellmetimeActivity.MODE_BACKGROUND_IMAGE:
        try {
            ((ImageView) findViewById(R.id.background_image)).setImageBitmap(BitmapFactory.decodeStream(
                    new FileInputStream(new File(getFilesDir(), TellmetimeActivity.IMAGE_FILE_NAME))));
        } catch (Exception ignored) {
            // Image is not set, set background color loaded from setting is visible.
        }

        break;
    }

    mShorterEdge = Math.min(getResources().getDisplayMetrics().widthPixels,
            getResources().getDisplayMetrics().heightPixels);
    mDensity = getResources().getDisplayMetrics().density;

    RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT,
            FrameLayout.LayoutParams.WRAP_CONTENT);
    lp.addRule(RelativeLayout.CENTER_IN_PARENT);
    lp.width = mShorterEdge;
    mClock.setLayoutParams(lp);

    Typeface mTypeface = Typeface.createFromAsset(getAssets(), "Roboto-BoldCondensed.ttf");
    final float mItemSize = mShorterEdge / mClock.getChildCount();
    final int mRowMargin = (int) -(mItemSize / 2.2);

    for (int i = 0; i < mClock.getChildCount(); i++) {
        LinearLayout row = (LinearLayout) mClock.getChildAt(i);

        LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) row.getLayoutParams();
        params.bottomMargin = mRowMargin;
        row.setLayoutParams(params);

        for (int j = 0; j < row.getChildCount(); j++) {
            TextView tv = (TextView) row.getChildAt(j);

            tv.setTypeface(mTypeface);
            tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, mItemSize);
            tv.setTextColor(mBacklightColor);
            tv.setShadowLayer(mShorterEdge / 200 * mDensity, 0, 0, mBacklightColor);
        }
    }
    LinearLayout lastRow = (LinearLayout) mClock.getChildAt(mClock.getChildCount() - 1);
    LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) lastRow.getLayoutParams();
    params.bottomMargin = 0;
    lastRow.setLayoutParams(params);

    TextView twenty = (TextView) findViewById(R.id.twenty);
    params = (LinearLayout.LayoutParams) twenty.getLayoutParams();
    params.leftMargin = 0;
    twenty.setLayoutParams(params);

    inflateMinutesIndicators();
}