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:com.intuit.qboecoui.email.SalesFormEmail.java

/**
 * This method customizes the sales form email form based on the transaction
 * type and company file preferences. This determines if preferences for
 * online payment will be displayed or not.
 *///from www.j ava 2s  . c  o  m
private void customizeSalesFormEmailForm() {

    if (mTransactionType == TXN_TYPE.INVOICE) {
        // We will show the online payment options only if the company file
        // is a Harmony file.
        // EInvoicing is enabled and MAS subscription is paid.
        if (Util.isNeoEnabled()) {
            LinearLayout onlinePaymentPreferencesContainer = (LinearLayout) findViewById(
                    R.id.pref_online_payment_container);
            if (onlinePaymentPreferencesContainer != null && SalesFormEmail.ETransactionEnabledStatus_ENABLED
                    .equalsIgnoreCase(mETransactionEnabledStatus) && mETransactionPaymentEnabled) {
                // Show these preferences
                onlinePaymentPreferencesContainer.setVisibility(View.VISIBLE);
            }
            if (Util.shouldBankTransferOptionBeShown()) {
                onlinePaymentPreferencesContainer.findViewById(R.id.pref_bank_transfer)
                        .setVisibility(View.VISIBLE);
            } else {
                onlinePaymentPreferencesContainer.findViewById(R.id.pref_bank_transfer)
                        .setVisibility(View.GONE);
            }
        }
    }
}

From source file:com.vk.sdk.dialogs.VKShareDialog.java

@NonNull
@Override//from w w w  . java 2 s .c om
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Context context = getActivity();
    View mInternalView = LayoutInflater.from(context).inflate(R.layout.vk_share_dialog, null);

    assert mInternalView != null;

    mSendButton = (Button) mInternalView.findViewById(R.id.sendButton);
    mSendProgress = (ProgressBar) mInternalView.findViewById(R.id.sendProgress);
    mPhotoLayout = (LinearLayout) mInternalView.findViewById(R.id.imagesContainer);
    mShareTextField = (EditText) mInternalView.findViewById(R.id.shareText);
    mPhotoScroll = (HorizontalScrollView) mInternalView.findViewById(R.id.imagesScrollView);

    LinearLayout mAttachmentLinkLayout = (LinearLayout) mInternalView.findViewById(R.id.attachmentLinkLayout);

    mSendButton.setOnClickListener(sendButtonPress);

    //Attachment text
    if (savedInstanceState != null) {
        mShareTextField.setText(savedInstanceState.getString(SHARE_TEXT_KEY));
        mAttachmentLink = savedInstanceState.getParcelable(SHARE_LINK_KEY);
        mAttachmentImages = (VKUploadImage[]) savedInstanceState.getParcelableArray(SHARE_IMAGES_KEY);
        mExistingPhotos = savedInstanceState.getParcelable(SHARE_UPLOADED_IMAGES_KEY);
    } else if (mAttachmentText != null) {
        mShareTextField.setText(mAttachmentText);
    }

    //Attachment photos
    mPhotoLayout.removeAllViews();
    if (mAttachmentImages != null) {
        for (VKUploadImage mAttachmentImage : mAttachmentImages) {
            addBitmapToPreview(mAttachmentImage.mImageData);
        }
        mPhotoLayout.setVisibility(View.VISIBLE);
    }

    if (mExistingPhotos != null) {
        processExistingPhotos();
    }
    if (mExistingPhotos == null && mAttachmentImages == null) {
        mPhotoLayout.setVisibility(View.GONE);
    }

    //Attachment link
    if (mAttachmentLink != null) {
        TextView linkTitle = (TextView) mAttachmentLinkLayout.findViewById(R.id.linkTitle),
                linkHost = (TextView) mAttachmentLinkLayout.findViewById(R.id.linkHost);

        linkTitle.setText(mAttachmentLink.linkTitle);
        linkHost.setText(VKUtil.getHost(mAttachmentLink.linkUrl));
        mAttachmentLinkLayout.setVisibility(View.VISIBLE);
    } else {
        mAttachmentLinkLayout.setVisibility(View.GONE);
    }
    Dialog result = new Dialog(context);
    result.requestWindowFeature(Window.FEATURE_NO_TITLE);
    result.setContentView(mInternalView);
    result.setCancelable(true);
    result.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialogInterface) {
            if (mListener != null) {
                mListener.onVkShareCancel();
            }
            VKShareDialog.this.dismiss();
        }
    });
    return result;
}

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;//  www .j a v  a  2 s  . 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.forrestguice.suntimeswidget.SuntimesActivity.java

/**
 * Stretch the horizontal rule to match the actual table width.. this is a hack to work around
 * unwanted stretching of the GridLayout columns when setting the hr to match_parent or fill_parent.
 *///w  w w.  j  a  v a 2  s . c  o  m
private void stretchTableRule() {
    LinearLayout[] cards = new LinearLayout[2];
    cards[0] = (LinearLayout) findViewById(R.id.info_time_all_today);
    cards[1] = (LinearLayout) findViewById(R.id.info_time_all_tomorrow);
    for (LinearLayout card : cards) // for each card
    {
        View tableRule = card.findViewById(R.id.table_rule);
        if (tableRule != null) {
            LinearLayout[] cols = new LinearLayout[3];
            cols[0] = (LinearLayout) card.findViewById(R.id.table_head_date);
            cols[1] = (LinearLayout) card.findViewById(R.id.table_head_rise);
            cols[2] = (LinearLayout) card.findViewById(R.id.table_head_set);

            int tableWidth = 0;
            for (LinearLayout col : cols) // add up the measured column widths
            {
                if (col != null) {
                    col.measure(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                    tableWidth += col.getMeasuredWidth();
                }
            }

            ViewGroup.LayoutParams tableRuleParams = tableRule.getLayoutParams();
            tableRuleParams.width = tableWidth;
            tableRule.setLayoutParams(tableRuleParams); // and adjust the horizontal rule width
        }
    }
}

From source file:com.plined.liftlog.WorkoutInstanceFragment.java

public void configureLabelRow(LinearLayout layoutRoot, String leftLabel, String rightLabel) {
    TextView leftTv = (TextView) layoutRoot.findViewById(R.id.t_workout_instance_header_element_leftText);
    leftTv.setText(leftLabel);// w ww .j a v a2 s . co m

    TextView rightTv = (TextView) layoutRoot.findViewById(R.id.t_workout_instance_header_element_rightText);
    rightTv.setText(rightLabel);
}

From source file:com.forrestguice.suntimeswidget.SuntimesActivity.java

/**
 * initialize the note flipper and associated views
 * @param context a context used to access resources
 *//*from www . jav a2 s .  com*/
private void initNoteViews(Context context) {
    note_progress = (ProgressBar) findViewById(R.id.info_note_progress);
    if (note_progress != null) {
        note_progress.setVisibility(View.GONE);
    }

    note_flipper = (ViewFlipper) findViewById(R.id.info_note_flipper);
    if (note_flipper != null) {
        note_flipper.setOnTouchListener(noteTouchListener);
        note_flipper.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                /* DO NOTHING HERE (but we still need this listener) */ }
        });

    } else {
        Log.w("initNoteViews", "Failed to set touchListener; note_flipper is null!");
    }

    LinearLayout note1 = (LinearLayout) findViewById(R.id.info_time_note1);
    if (note1 != null) {
        txt_time1_note1 = (TextView) note1.findViewById(R.id.text_timenote1);
        txt_time1_note2 = (TextView) note1.findViewById(R.id.text_timenote2);
        txt_time1_note3 = (TextView) note1.findViewById(R.id.text_timenote3);
        ic_time1_note = (ImageView) note1.findViewById(R.id.icon_timenote);
        ic_time1_note.setVisibility(View.INVISIBLE);

    } else {
        Log.w("initNoteViews", "Failed to init note layout1; was null!");
    }

    LinearLayout note2 = (LinearLayout) findViewById(R.id.info_time_note2);
    if (note2 != null) {
        txt_time2_note1 = (TextView) note2.findViewById(R.id.text_timenote1);
        txt_time2_note2 = (TextView) note2.findViewById(R.id.text_timenote2);
        txt_time2_note3 = (TextView) note2.findViewById(R.id.text_timenote3);
        ic_time2_note = (ImageView) note2.findViewById(R.id.icon_timenote);
        ic_time2_note.setVisibility(View.INVISIBLE);

    } else {
        Log.w("initNoteViews", "Failed to init note layout2; was null!");
    }
}

From source file:com.plined.liftlog.WorkoutInstanceFragment.java

private void configureHeaderOnClick() {
    LinearLayout bottomRow = (LinearLayout) mHeaderView.findViewById(R.id.t_workout_instance_header_rotDate);
    //Get the right side element
    View rightElement = bottomRow.findViewById(R.id.t_workout_instance_header_element_rightText);

    //Set the onclick listener
    rightElement.setOnClickListener(new View.OnClickListener() {

        @Override/*from   w w w  .j a v  a 2s.  c om*/
        public void onClick(View v) {
            //They hit the add exercise button. Launch the dialog to add exercise.
            DateTimeSelectDialog fragToUse = DateTimeSelectDialog.newInstance(mRoutineInstance.getId());

            //Launch this fragment.
            launchDialogFragmentTarget(fragToUse, "setroutineinstancedatetime", REQUEST_SET_DATE);
        }
    });
}

From source file:com.mantz_it.rfanalyzer.MainActivity.java

/**
 * Will pop up a dialog to let the user input a new frequency.
 * Note: A frequency can be entered either in Hz or in MHz. If the input value
 * is a number smaller than the maximum frequency of the source in MHz, then it
 * is interpreted as a frequency in MHz. Otherwise it will be handled as frequency
 * in Hz.//  w ww  .  j  a  v a  2s. c  o  m
 */
private void tuneToFrequency() {
    if (source == null)
        return;

    // calculate max frequency of the source in MHz:
    final double maxFreqMHz = source.getMaxFrequency() / 1000000f;

    final LinearLayout ll_view = (LinearLayout) this.getLayoutInflater().inflate(R.layout.tune_to_frequency,
            null);
    final EditText et_frequency = (EditText) ll_view.findViewById(R.id.et_tune_to_frequency);
    final Spinner sp_unit = (Spinner) ll_view.findViewById(R.id.sp_tune_to_frequency_unit);
    final CheckBox cb_bandwidth = (CheckBox) ll_view.findViewById(R.id.cb_tune_to_frequency_bandwidth);
    final EditText et_bandwidth = (EditText) ll_view.findViewById(R.id.et_tune_to_frequency_bandwidth);
    final Spinner sp_bandwidthUnit = (Spinner) ll_view.findViewById(R.id.sp_tune_to_frequency_bandwidth_unit);
    final TextView tv_warning = (TextView) ll_view.findViewById(R.id.tv_tune_to_frequency_warning);

    // Show warning if we are currently recording to file:
    if (recordingFile != null)
        tv_warning.setVisibility(View.VISIBLE);

    cb_bandwidth.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            et_bandwidth.setEnabled(isChecked);
            sp_bandwidthUnit.setEnabled(isChecked);
        }
    });
    cb_bandwidth.toggle(); // to trigger the onCheckedChangeListener at least once to set inital state
    cb_bandwidth
            .setChecked(preferences.getBoolean(getString(R.string.pref_tune_to_frequency_setBandwidth), false));
    et_bandwidth.setText(preferences.getString(getString(R.string.pref_tune_to_frequency_bandwidth), "1"));
    sp_unit.setSelection(preferences.getInt(getString(R.string.pref_tune_to_frequency_unit), 0));
    sp_bandwidthUnit
            .setSelection(preferences.getInt(getString(R.string.pref_tune_to_frequency_bandwidthUnit), 0));

    new AlertDialog.Builder(this).setTitle("Tune to Frequency")
            .setMessage(String.format("Frequency is %f MHz. Type a new Frequency: ",
                    source.getFrequency() / 1000000f))
            .setView(ll_view).setPositiveButton("Set", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    try {
                        double newFreq = source.getFrequency();
                        if (et_frequency.getText().length() != 0)
                            newFreq = Double.valueOf(et_frequency.getText().toString());
                        if (sp_unit.getSelectedItemPosition() == 0) //MHz
                            newFreq *= 1000000;
                        else if (sp_unit.getSelectedItemPosition() == 1) //KHz
                            newFreq *= 1000;
                        if (newFreq <= source.getMaxFrequency() && newFreq >= source.getMinFrequency()) {
                            source.setFrequency((long) newFreq);
                            analyzerSurface.setVirtualFrequency((long) newFreq);
                            if (demodulationMode != Demodulator.DEMODULATION_OFF)
                                analyzerSurface.setDemodulationEnabled(true); // This will re-adjust the channel freq correctly

                            // Set bandwidth (virtual sample rate):
                            if (cb_bandwidth.isChecked() && et_bandwidth.getText().length() != 0) {
                                float bandwidth = Float.valueOf(et_bandwidth.getText().toString());
                                if (sp_bandwidthUnit.getSelectedItemPosition() == 0) //MHz
                                    bandwidth *= 1000000;
                                else if (sp_bandwidthUnit.getSelectedItemPosition() == 1) //KHz
                                    bandwidth *= 1000;
                                if (bandwidth > source.getMaxSampleRate())
                                    bandwidth = source.getMaxFrequency();
                                source.setSampleRate(source.getNextHigherOptimalSampleRate((int) bandwidth));
                                analyzerSurface.setVirtualSampleRate((int) bandwidth);
                            }
                            // safe preferences:
                            SharedPreferences.Editor edit = preferences.edit();
                            edit.putInt(getString(R.string.pref_tune_to_frequency_unit),
                                    sp_unit.getSelectedItemPosition());
                            edit.putBoolean(getString(R.string.pref_tune_to_frequency_setBandwidth),
                                    cb_bandwidth.isChecked());
                            edit.putString(getString(R.string.pref_tune_to_frequency_bandwidth),
                                    et_bandwidth.getText().toString());
                            edit.putInt(getString(R.string.pref_tune_to_frequency_bandwidthUnit),
                                    sp_bandwidthUnit.getSelectedItemPosition());
                            edit.apply();

                        } else {
                            Toast.makeText(MainActivity.this,
                                    "Frequency is out of the valid range: " + (long) newFreq + " Hz",
                                    Toast.LENGTH_LONG).show();
                        }
                    } catch (NumberFormatException e) {
                        Log.e(LOGTAG, "tuneToFrequency: Error while setting frequency: " + e.getMessage());
                    }
                }
            }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    // do nothing
                }
            }).show();
}

From source file:com.forrestguice.suntimeswidget.SuntimesActivity.java

/**
 * initialize the card flipper and associated views
 * @param context a context used to access resources
 *///from  w  w w . ja va 2 s  .c  o  m
private void initCardViews(Context context) {
    timeFields = new HashMap<SolarEvents.SolarEventField, TextView>();
    card_flipper = (ViewFlipper) findViewById(R.id.info_time_flipper);
    if (card_flipper != null) {
        card_flipper.setOnTouchListener(timeCardTouchListener);
    } else {
        Log.w("initCardViews", "Failed to set touchListener; card_flipper was null!");
    }

    // Today's times
    LinearLayout viewToday = (LinearLayout) findViewById(R.id.info_time_all_today);
    if (viewToday != null) {
        txt_date = (TextView) viewToday.findViewById(R.id.text_date);
        txt_date.setOnClickListener(dateTapClickListener(false));

        txt_sunrise_actual = (TextView) viewToday.findViewById(R.id.text_time_sunrise_actual);
        txt_sunset_actual = (TextView) viewToday.findViewById(R.id.text_time_sunset_actual);
        timeFields.put(new SolarEvents.SolarEventField(SolarEvents.SUNRISE, false), txt_sunrise_actual);
        timeFields.put(new SolarEvents.SolarEventField(SolarEvents.SUNSET, false), txt_sunset_actual);

        txt_sunrise_civil = (TextView) viewToday.findViewById(R.id.text_time_sunrise_civil);
        txt_sunset_civil = (TextView) viewToday.findViewById(R.id.text_time_sunset_civil);
        timeFields.put(new SolarEvents.SolarEventField(SolarEvents.MORNING_CIVIL, false), txt_sunrise_civil);
        timeFields.put(new SolarEvents.SolarEventField(SolarEvents.EVENING_CIVIL, false), txt_sunset_civil);

        txt_sunrise_nautical = (TextView) viewToday.findViewById(R.id.text_time_sunrise_nautical);
        txt_sunset_nautical = (TextView) viewToday.findViewById(R.id.text_time_sunset_nautical);
        timeFields.put(new SolarEvents.SolarEventField(SolarEvents.MORNING_NAUTICAL, false),
                txt_sunrise_nautical);
        timeFields.put(new SolarEvents.SolarEventField(SolarEvents.EVENING_NAUTICAL, false),
                txt_sunset_nautical);

        txt_sunrise_astro = (TextView) viewToday.findViewById(R.id.text_time_sunrise_astro);
        txt_sunset_astro = (TextView) viewToday.findViewById(R.id.text_time_sunset_astro);
        timeFields.put(new SolarEvents.SolarEventField(SolarEvents.MORNING_ASTRONOMICAL, false),
                txt_sunrise_astro);
        timeFields.put(new SolarEvents.SolarEventField(SolarEvents.EVENING_ASTRONOMICAL, false),
                txt_sunset_astro);

        txt_solarnoon = (TextView) viewToday.findViewById(R.id.text_time_noon);
        timeFields.put(new SolarEvents.SolarEventField(SolarEvents.NOON, false), txt_solarnoon);

        layout_daylength = (LinearLayout) viewToday.findViewById(R.id.layout_daylength);
        txt_daylength = (TextView) viewToday.findViewById(R.id.text_daylength);
        txt_lightlength = (TextView) viewToday.findViewById(R.id.text_lightlength);

        btn_flipperNext_today = (ImageButton) viewToday.findViewById(R.id.info_time_nextbtn);
        btn_flipperNext_today.setOnClickListener(onNextCardClick);
        btn_flipperNext_today.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View view, MotionEvent motionEvent) {
                if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
                    btn_flipperNext_today.setColorFilter(
                            ContextCompat.getColor(SuntimesActivity.this, R.color.btn_tint_pressed));
                } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
                    btn_flipperNext_today.setColorFilter(null);
                }
                return false;
            }
        });

        btn_flipperPrev_today = (ImageButton) viewToday.findViewById(R.id.info_time_prevbtn);
        btn_flipperPrev_today.setOnClickListener(onPrevCardClick);
        btn_flipperPrev_today.setVisibility(View.GONE);

    } else {
        Log.w("initCardViews", "Failed to init card layout1; was null!");
    }

    // Tomorrow's times
    LinearLayout viewTomorrow = (LinearLayout) findViewById(R.id.info_time_all_tomorrow);
    if (viewTomorrow != null) {
        txt_date2 = (TextView) viewTomorrow.findViewById(R.id.text_date);
        txt_date2.setOnClickListener(dateTapClickListener(true));

        txt_sunrise2_actual = (TextView) viewTomorrow.findViewById(R.id.text_time_sunrise_actual);
        txt_sunset2_actual = (TextView) viewTomorrow.findViewById(R.id.text_time_sunset_actual);
        timeFields.put(new SolarEvents.SolarEventField(SolarEvents.SUNRISE, true), txt_sunrise2_actual);
        timeFields.put(new SolarEvents.SolarEventField(SolarEvents.SUNSET, true), txt_sunset2_actual);

        txt_sunrise2_civil = (TextView) viewTomorrow.findViewById(R.id.text_time_sunrise_civil);
        txt_sunset2_civil = (TextView) viewTomorrow.findViewById(R.id.text_time_sunset_civil);
        timeFields.put(new SolarEvents.SolarEventField(SolarEvents.MORNING_CIVIL, true), txt_sunrise2_civil);
        timeFields.put(new SolarEvents.SolarEventField(SolarEvents.EVENING_CIVIL, true), txt_sunset2_civil);

        txt_sunrise2_nautical = (TextView) viewTomorrow.findViewById(R.id.text_time_sunrise_nautical);
        txt_sunset2_nautical = (TextView) viewTomorrow.findViewById(R.id.text_time_sunset_nautical);
        timeFields.put(new SolarEvents.SolarEventField(SolarEvents.MORNING_NAUTICAL, true),
                txt_sunrise2_nautical);
        timeFields.put(new SolarEvents.SolarEventField(SolarEvents.EVENING_NAUTICAL, true),
                txt_sunset2_nautical);

        txt_sunrise2_astro = (TextView) viewTomorrow.findViewById(R.id.text_time_sunrise_astro);
        txt_sunset2_astro = (TextView) viewTomorrow.findViewById(R.id.text_time_sunset_astro);
        timeFields.put(new SolarEvents.SolarEventField(SolarEvents.MORNING_ASTRONOMICAL, true),
                txt_sunrise2_astro);
        timeFields.put(new SolarEvents.SolarEventField(SolarEvents.EVENING_ASTRONOMICAL, true),
                txt_sunset2_astro);

        txt_solarnoon2 = (TextView) viewTomorrow.findViewById(R.id.text_time_noon);
        timeFields.put(new SolarEvents.SolarEventField(SolarEvents.NOON, true), txt_solarnoon2);

        layout_daylength2 = (LinearLayout) viewTomorrow.findViewById(R.id.layout_daylength);
        txt_daylength2 = (TextView) viewTomorrow.findViewById(R.id.text_daylength);
        txt_lightlength2 = (TextView) viewTomorrow.findViewById(R.id.text_lightlength);

        btn_flipperNext_tomorrow = (ImageButton) viewTomorrow.findViewById(R.id.info_time_nextbtn);
        btn_flipperNext_tomorrow.setOnClickListener(onNextCardClick);
        btn_flipperNext_tomorrow.setVisibility(View.GONE);

        btn_flipperPrev_tomorrow = (ImageButton) viewTomorrow.findViewById(R.id.info_time_prevbtn);
        btn_flipperPrev_tomorrow.setOnClickListener(onPrevCardClick);
        btn_flipperPrev_tomorrow.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View view, MotionEvent motionEvent) {
                if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
                    btn_flipperPrev_tomorrow.setColorFilter(
                            ContextCompat.getColor(SuntimesActivity.this, R.color.btn_tint_pressed));
                } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
                    btn_flipperPrev_tomorrow.setColorFilter(null);
                }
                return false;
            }
        });

        initTimeFields();

    } else {
        Log.w("initCardViews", "Failed to init card layout2; was null!");
    }

    stretchTableRule();
}

From source file:com.afwsamples.testdpc.policy.PolicyManagementFragment.java

/**
 * Shows a prompt to ask for package name which is used to enable a system app.
 *//*from  ww w.jav  a  2 s .  co m*/
private void showEnableSystemAppByPackageNamePrompt() {
    if (getActivity() == null || getActivity().isFinishing()) {
        return;
    }
    LinearLayout inputContainer = (LinearLayout) getActivity().getLayoutInflater()
            .inflate(R.layout.simple_edittext, null);
    final EditText editText = (EditText) inputContainer.findViewById(R.id.input);
    editText.setHint(getString(R.string.enable_system_apps_by_package_name_hints));

    new AlertDialog.Builder(getActivity()).setTitle(getString(R.string.enable_system_apps_title))
            .setView(inputContainer)
            .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    final String packageName = editText.getText().toString();
                    try {
                        mDevicePolicyManager.enableSystemApp(mAdminComponentName, packageName);
                        showToast(R.string.enable_system_apps_by_package_name_success_msg, packageName);
                    } catch (IllegalArgumentException e) {
                        showToast(R.string.enable_system_apps_by_package_name_error);
                    } finally {
                        dialog.dismiss();
                    }
                }
            }).setNegativeButton(android.R.string.cancel, null).show();
}