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:org.ounl.lifelonglearninghub.learntracker.gis.ou.swipe.DayFragment.java

public void inflateLayout(int iPos) {

    String sIdSubject = Session.getSingleInstance().getDatabaseHandler().getSubjects().get(iPos).getsId();

    // String sIdSubject = Session.getSingleInstance().getActivity(iPos).getId_subject();        
    long lDuration = Session.getSingleInstance().getDatabaseHandler().getAccumulatedTime(sIdSubject);

    // List of activities to inflate history
    List<ActividadDb> lADb = Session.getSingleInstance().getDatabaseHandler().getActivities(sIdSubject);

    // Duration/*from ww  w .j  a v a  2s  .  c o m*/
    DateUtils du = new DateUtils();
    TextView t = (TextView) rootView.findViewById(R.id.tvDuration);
    t.setText(du.duration(lDuration));

    // Time picker
    TimePicker timePicker = (TimePicker) rootView.findViewById(R.id.tpTask);
    timePicker.setIs24HourView(true);
    timePicker.setCurrentHour(0);
    timePicker.setCurrentMinute(45);

    // Button image view   
    ImageView iv = (ImageView) rootView.findViewById(R.id.ivActionActivity);
    int currentStatus = Session.getSingleInstance().getActivity(iPos).getStatus();
    if (currentStatus == ActivitySession.STATUS_STOPPED) {
        Drawable d = getResources().getDrawable(R.drawable.play);
        iv.setImageDrawable(d);
    } else {
        Drawable d = getResources().getDrawable(R.drawable.stop);
        iv.setImageDrawable(d);
    }

    // History      
    if (lADb.size() != 0) {

        LinearLayout llHistory = (LinearLayout) rootView.findViewById(R.id.llHistory);
        TextView tvHeader = (TextView) llHistory.findViewById(R.id.tvHeaderHisory);
        tvHeader.setVisibility(View.VISIBLE);

        for (int i = 0; i < lADb.size(); i++) {

            ActividadDb adb = lADb.get(i);

            LinearLayout llCheckItemWrapper = (LinearLayout) mInflater.inflate(R.layout.check_item, null);
            // Passing order as param so it can be removed
            llCheckItemWrapper.setTag(i);

            LinearLayout liContent = (LinearLayout) llCheckItemWrapper.getChildAt(0);

            TextView tvTimeStamp = (TextView) liContent.findViewById(R.id.textViewTimeStamp);
            tvTimeStamp.setText(Constants.TIME_FORMAT.format(adb.getlDateCheckIn()));
            // Passing checkin time in mills as tag
            tvTimeStamp.setTag(Long.valueOf(adb.getlDateCheckIn()));

            TextView tvDurRecord = (TextView) liContent.findViewById(R.id.textViewDuration);
            tvDurRecord.setText(" [" + du.duration(adb.getlDateCheckIn(), adb.getlDateCheckOut()) + "]");
            // Passing subject id as parameter        
            tvDurRecord.setTag(adb.getsIdSubject());

            llHistory.addView(mInflater.inflate(R.layout.tag_divider, llHistory, false), 1);
            llHistory.addView(llCheckItemWrapper, 2);

        }

    }

}

From source file:com.menu.menus.ScreenSlideActivity.java

public void manejadorPedido(View v) {

    // Obtiene el padre del boton, la fila del plato
    LinearLayout fila = (LinearLayout) v.getParent();

    // Obtiene datos del plato mediante su fila y posicion
    TextView nombre = (TextView) fila.getChildAt(0);
    TextView categoria = (TextView) fila.getChildAt(1);
    TextView precio = (TextView) fila.getChildAt(3);

    // Toast que muestra la info 
    //Toast t = Toast.makeText(v.getContext(), nombre.getText(), 100);
    //t.show();/*from w  w w  .  j av  a2s . c  o  m*/

    // Nuevo objeto para alamacenar el precio, unidades e importe del plato
    PrecioUndsImporte precUndsImp = new PrecioUndsImporte(Double.valueOf(precio.getText().toString()
            // Intercambio de . por , para poder convertirlo a Double
            .replace("\u20AC", " ").replace(",", "*").replace(".", ",").replace("*", ".")), 1,
            Double.valueOf(precio.getText().toString()
                    // Intercambio de . por , para poder convertirlo a Double
                    .replace("\u20AC", " ").replace(",", "*").replace(".", ",").replace("*", ".")));

    // Aade plato nuevo o suma 1 a la cantidad
    platosSeleccionados.setPlato(categoria.getText().toString(), nombre.getText().toString(), precUndsImp);

    // Establece la estructura de datos en el FragmentoComandas 
    FragmentoComanda.setPlatosSeleccionados(platosSeleccionados);

    /* 
     * Si la pagina actual es la 2 ya ha cargado la 3 (pagina de comanda), la 
     * tiene en memoria y procede a recoger su vista y aadir el plato y mostrar los almacenados.   
     * Este bucle se complementa con la carga y muestra de los platos cuando se carga 
     * la 3 (pagina de comanda), pagina cuya pulsacion en la pagina 2 no recoge.
     * */
    if (mPager.getCurrentItem() == 2) {

        // Recogida de fragment Comanda mostrado
        FragmentoComanda f = (FragmentoComanda) getSupportFragmentManager().findFragmentByTag("Comanda");

        if (platosSeleccionados.estaPlato(categoria.getText().toString(), nombre.getText().toString())) {

            /* 
             * Si esta el plato en la estructura limpiamos y mostramos toda la 
             * estructura. 
             */
            f.limpiaPlatos();
            // Al estar el plato en la estructura no es necesario el ultimo parametro
            platosSeleccionados.setPlato(categoria.getText().toString(), nombre.getText().toString(), null);
            f.setPlatosSeleccionados(platosSeleccionados);
            f.muestraPlatos();

        } else {

            // Aadir la fila con el nuevo plato(mas eficiente que volver a mostrar todo)
            f.setFila(nombre.getText(), precUndsImp.getPrecio().toString(), precUndsImp.getUnds().toString(),
                    precUndsImp.getImporte().toString(), categoria.getText());

        }

        f.setImporteTotal();

    }

}

From source file:org.nativescript.widgets.TabLayout.java

/**
 * Gets the TextView for tab item at index
 *//* w w w . j a v a2s  .  co m*/
public TextView getTextViewForItemAt(int index) {
    LinearLayout ll = this.getViewForItemAt(index);
    return (ll != null) ? (TextView) ll.getChildAt(1) : null;
}

From source file:org.apps8os.motivator.ui.AddEventActivity.java

/**
 * Actions for the menu items.//from ww w  .  j a v a2  s .c  o  m
 */
@Override
public boolean onOptionsItemSelected(MenuItem item) {

    // Adding the name for the event/plan
    if (item.getItemId() == R.id.questions_add_comment) {
        AlertDialog.Builder alert = new AlertDialog.Builder(this);
        alert.setTitle(getString(R.string.name_the_event));
        // Create TextView
        LinearLayout rootElement = (LinearLayout) getLayoutInflater()
                .inflate(R.layout.element_comment_edit_text, null);
        final EditText input = (EditText) rootElement.getChildAt(0);
        input.setText(mName);
        alert.setView(rootElement);

        alert.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                mName = input.getText().toString();
                getActionBar().setTitle(mName);
            }
        });

        alert.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                // Canceled.
            }
        });
        alert.show();
        return true;
    } else {
        return super.onOptionsItemSelected(item);
    }
}

From source file:org.nativescript.widgets.TabLayout.java

/**
 * Updates the UI of an item at specified index
 *///from w w w  .j  a  va 2s  .  c  om
public void updateItemAt(int position, TabItemSpec tabItem) {
    LinearLayout ll = (LinearLayout) mTabStrip.getChildAt(position);
    ImageView imgView = (ImageView) ll.getChildAt(0);
    TextView textView = (TextView) ll.getChildAt(1);
    this.setupItem(ll, textView, imgView, tabItem);
}

From source file:asu.edu.msse.gpeddabu.moviedescriptions.MovieListAdapter.java

@Override
public boolean onTouch(View v, MotionEvent event) {
    // when the user touches an item, onTouch is called for action down and again for action up
    // we only want to do something on one of those actions. event tells us which action.
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
        // onTouch is passed the textview's parent view, a linearlayout - what we set the
        // event on. Look at its children to find the textview
        if (v instanceof android.widget.LinearLayout) {
            android.widget.LinearLayout layView = (android.widget.LinearLayout) v;
            // the layout (from list_item.xml should only have one child, but, here's how
            // you find the children of a layout or other view group.
            for (int i = 0; i <= layView.getChildCount(); i++) {
                if (layView.getChildAt(i) instanceof TextView) {
                    // keep track of TV stuff was most recently touched to un-highlighted
                    if (currSelection != null) {
                        currSelection.setBackgroundColor(parent.getResources().getColor(R.color.light_blue));
                    }//w w  w  .j  a v  a  2 s .  c o  m
                    TextView tmp = ((TextView) layView.getChildAt(i));
                    currSelection = tmp;
                    parent.setSelectedStuff(tmp.getText().toString());
                    // create an intent (in the name of the parent activity) to start the WebViewActivity
                    // pass the web view activity two strings: the url and the name of the selected item.
                    // expect the WebViewActivity to return a result, which will be picked up in the
                    // requesting activity -- MainActivity.
                    Intent movieDetails = new Intent(parent, MovieDetails.class);
                    //                        movieDetails.putExtra("MovieLibrary",(parent.movieLibrary));
                    movieDetails.putExtra("movieName", ((TextView) layView.getChildAt(i)).getText().toString());
                    //                        try {
                    //                            movieDetails.putExtra("genreName", getGenre(((TextView) layView.getChildAt(i)).getText().toString()));
                    //                        } catch (JSONException e) {
                    //                            e.printStackTrace();
                    //                        };
                    parent.startActivity(movieDetails);
                }
            }
        }
        // code below should never executes. onTouch is called for textview's linearlayout parent
        if (v instanceof TextView) {
            android.util.Log.d(this.getClass().getSimpleName(),
                    "in onTouch called for: " + ((TextView) v).getText());
        }
    }
    return true;
}

From source file:ca.xef6.firecamp.ProfilePictureSampleFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
    View fragmentView = inflater.inflate(R.layout.fragment_profile_picture_sample, parent, false);

    randomGenerator = new Random((new Date()).getTime());

    profilePic = (ProfilePictureView) fragmentView.findViewById(R.id.profilepic);
    smallerButton = (Button) fragmentView.findViewById(R.id.smallerButton);
    largerButton = (Button) fragmentView.findViewById(R.id.largerButton);
    sizeLabel = (TextView) fragmentView.findViewById(R.id.sizeLabel);
    presetSizeView = fragmentView.findViewById(R.id.presetSizeView);
    customSizeView = (SeekBar) fragmentView.findViewById(R.id.customSizeView);
    cropToggle = (CheckBox) fragmentView.findViewById(R.id.squareCropToggle);

    LinearLayout container = (LinearLayout) fragmentView.findViewById(R.id.userbuttoncontainer);
    int numChildren = container.getChildCount();
    for (int i = 0; i < numChildren; i++) {
        View childView = container.getChildAt(i);
        Object tag = childView.getTag();
        if (childView instanceof Button) {
            setupUserButton((Button) childView);
            if (i == 0) {
                // Initialize the image to the first user
                firstUserId = tag.toString();
            }/* w  w w .  j ava2 s . c  om*/
        }
    }

    cropToggle.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean checked) {
            profilePic.setCropped(checked);
        }
    });

    final Button sizeToggle = (Button) fragmentView.findViewById(R.id.sizeToggle);
    sizeToggle.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (pictureSizeType != ProfilePictureView.CUSTOM) {
                sizeToggle.setText("preset size button text");
                switchToCustomSize();
            } else {
                sizeToggle.setText("custom size button text");
                switchToPresetSize(ProfilePictureView.LARGE);
            }
        }
    });

    smallerButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            switch (profilePic.getPresetSize()) {
            case ProfilePictureView.LARGE:
                switchToPresetSize(ProfilePictureView.NORMAL);
                break;
            case ProfilePictureView.NORMAL:
                switchToPresetSize(ProfilePictureView.SMALL);
                break;
            }
        }
    });

    largerButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            switch (profilePic.getPresetSize()) {
            case ProfilePictureView.NORMAL:
                switchToPresetSize(ProfilePictureView.LARGE);
                break;
            case ProfilePictureView.SMALL:
                switchToPresetSize(ProfilePictureView.NORMAL);
                break;
            }
        }
    });

    // We will fetch a new image for each change in the SeekBar. So keeping the count low
    // to prevent too much network chatter. SeekBar reports 0-max, so we will get max+1
    // notifications of change.
    customSizeView.setMax(MAX_CUSTOM_SIZES);
    customSizeView.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
            updateProfilePicForCustomSizeIncrement(i);
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            // NO-OP
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            // NO-OP
        }
    });

    restoreState(savedInstanceState);

    return fragmentView;
}

From source file:com.facebook.samples.profilepicture.ProfilePictureSampleFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
    View fragmentView = inflater.inflate(R.layout.fragment_profile_picture_sample, parent, false);

    randomGenerator = new Random((new Date()).getTime());

    profilePic = (ProfilePictureView) fragmentView.findViewById(R.id.profilepic);
    smallerButton = (Button) fragmentView.findViewById(R.id.smallerButton);
    largerButton = (Button) fragmentView.findViewById(R.id.largerButton);
    sizeLabel = (TextView) fragmentView.findViewById(R.id.sizeLabel);
    presetSizeView = fragmentView.findViewById(R.id.presetSizeView);
    customSizeView = (SeekBar) fragmentView.findViewById(R.id.customSizeView);
    cropToggle = (CheckBox) fragmentView.findViewById(R.id.squareCropToggle);

    LinearLayout container = (LinearLayout) fragmentView.findViewById(R.id.userbuttoncontainer);
    int numChildren = container.getChildCount();
    for (int i = 0; i < numChildren; i++) {
        View childView = container.getChildAt(i);
        Object tag = childView.getTag();
        if (childView instanceof Button) {
            setupUserButton((Button) childView);
            if (i == 0) {
                // Initialize the image to the first user
                firstUserId = tag.toString();
            }/*w ww. j a  v  a  2s.  c  om*/
        }
    }

    cropToggle.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean checked) {
            profilePic.setCropped(checked);
        }
    });

    final Button sizeToggle = (Button) fragmentView.findViewById(R.id.sizeToggle);
    sizeToggle.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (pictureSizeType != ProfilePictureView.CUSTOM) {
                sizeToggle.setText(R.string.preset_size_button_text);
                switchToCustomSize();
            } else {
                sizeToggle.setText(R.string.custom_size_button_text);
                switchToPresetSize(ProfilePictureView.LARGE);
            }
        }
    });

    smallerButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            switch (profilePic.getPresetSize()) {
            case ProfilePictureView.LARGE:
                switchToPresetSize(ProfilePictureView.NORMAL);
                break;
            case ProfilePictureView.NORMAL:
                switchToPresetSize(ProfilePictureView.SMALL);
                break;
            }
        }
    });

    largerButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            switch (profilePic.getPresetSize()) {
            case ProfilePictureView.NORMAL:
                switchToPresetSize(ProfilePictureView.LARGE);
                break;
            case ProfilePictureView.SMALL:
                switchToPresetSize(ProfilePictureView.NORMAL);
                break;
            }
        }
    });

    // We will fetch a new image for each change in the SeekBar. So keeping the count low
    // to prevent too much network chatter. SeekBar reports 0-max, so we will get max+1
    // notifications of change.
    customSizeView.setMax(MAX_CUSTOM_SIZES);
    customSizeView.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
            updateProfilePicForCustomSizeIncrement(i);
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            // NO-OP
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            // NO-OP
        }
    });

    restoreState(savedInstanceState);

    return fragmentView;
}

From source file:com.itude.mobile.mobbl.core.view.components.tabbar.MBDefaultActionBarBuilder.java

protected void setSearchImage(Drawable image, LinearLayout linearLayout) {
    ImageView searchViewIcon = null;

    for (int i = 0; i < linearLayout.getChildCount(); i++) {
        View view = linearLayout.getChildAt(i);
        if (view instanceof ImageView) {
            searchViewIcon = (ImageView) view;
            break;
        }/*from   w  ww  . j  ava 2 s.c o  m*/
    }
    searchViewIcon.setImageDrawable(image);
}

From source file:cs.man.ac.uk.tavernamobile.fragments.SearchResultFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    // remove menu added by previous fragment
    for (int i = 1; i < menu.size(); i++) {
        menu.removeItem(menu.getItem(i).getItemId());
    }/*  w  w w .  ja v a 2  s.  co  m*/
    parentActivity.getMenuInflater().inflate(R.menu.search_results_screen, menu);
    LinearLayout searchView = (LinearLayout) menu.findItem(R.id.search_results_search).getActionView();

    final EditText query = (EditText) searchView.getChildAt(0);
    query.requestFocus();
    query.setOnEditorActionListener(new EditText.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEARCH) {
                searchQuery = query.getText().toString();
                search(searchQuery);
                return true;
            }
            return false;
        }
    });
    ImageButton searchButton = (ImageButton) searchView.getChildAt(1);

    searchButton.setOnClickListener(new android.view.View.OnClickListener() {
        public void onClick(android.view.View v) {
            searchQuery = query.getText().toString();
            search(searchQuery);
        }
    });
    super.onPrepareOptionsMenu(menu);
}