Example usage for android.view View findViewById

List of usage examples for android.view View findViewById

Introduction

In this page you can find the example usage for android.view View 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.loadsensing.app.LlistaXarxesActivity.java

protected void onListItemClick(ListView l, View v, int position, long id) {
    // obtenim el valor de la xarxa amb el camp ocult text6 del layout i obrim la nova pantalla de llistat de sensors
    TextView c = (TextView) v.findViewById(R.id.text6);
    String idxarxaselected = c.getText().toString();

    Intent intent = new Intent();
    intent.setClass(this.getApplicationContext(), SensorsActivity.class);
    intent.putExtra("idxarxaselected", idxarxaselected);
    startActivity(intent);//from  ww w .j a v  a2  s . c o  m

}

From source file:com.ateam.alleneatonautorentals.SalesViewReservations.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.view_reservations);

    Intent getIntent = getIntent();/*from w w w  .  j  a v  a 2  s.co  m*/
    userEmail = getIntent.getStringExtra("email");
    key = getIntent.getStringExtra("key");
    name = getIntent.getStringExtra("name");

    resList = new ArrayList<HashMap<String, String>>();

    new LoadAllUserRes().execute();

    ListView lv = getListView();

    lv.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            String gps = ((TextView) view.findViewById(R.id.carres_GPS_list)).getText().toString();
            String child_seat = ((TextView) view.findViewById(R.id.carres_child_seat_list)).getText()
                    .toString();
            String k_tag = ((TextView) view.findViewById(R.id.carres_k_tag_list)).getText().toString();
            String assistance = ((TextView) view.findViewById(R.id.carres_assistance_list)).getText()
                    .toString();
            String dinsurance = ((TextView) view.findViewById(R.id.carres_dinsurance_list)).getText()
                    .toString();
            String ainsurance = ((TextView) view.findViewById(R.id.carres_ainsurance_list)).getText()
                    .toString();
            String state = ((TextView) view.findViewById(R.id.carres_state_list)).getText().toString();
            String city = ((TextView) view.findViewById(R.id.carres_city_list)).getText().toString();
            String start_date = ((TextView) view.findViewById(R.id.carres_start_list)).getText().toString();
            String end_date = ((TextView) view.findViewById(R.id.carres_end_list)).getText().toString();
            String carid = ((TextView) view.findViewById(R.id.carres_id_list)).getText().toString();

            Intent ii = new Intent(getApplicationContext(), SalesCheckoutCar.class);

            ii.putExtra("carid", carid);
            ii.putExtra("state", state);
            ii.putExtra("city", city);
            ii.putExtra("start_date", start_date);
            ii.putExtra("end_date", end_date);
            ii.putExtra("gps", gps);
            ii.putExtra("child_seat", child_seat);
            ii.putExtra("ktag", k_tag);
            ii.putExtra("assistance", assistance);
            ii.putExtra("dinsurance", dinsurance);
            ii.putExtra("ainsurance", ainsurance);
            ii.putExtra("reservation", "1");
            ii.putExtra("email", userEmail);
            ii.putExtra("key", key);
            ii.putExtra("name", name);

            startActivity(ii);
            finish();
        }

    });
}

From source file:com.akoscz.youtube.YouTubeFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    Picasso.with(getActivity()).setDebugging(true);

    View rootView = inflater.inflate(R.layout.youtube_fragment, container, false);

    mListView = (ListView) rootView.findViewById(R.id.youtube_listview);

    // restore the playlist after an orientation change
    if (savedInstanceState != null) {
        mPlaylist = new Gson().fromJson(savedInstanceState.getString(PLAYLIST_KEY), Playlist.class);
    }//www  .  j  a v a 2  s .  c  o m

    // ensure the adapter and listview are initialized
    if (mPlaylist != null) {
        initListAdapter(mPlaylist);
    }

    // start loading the first page of our playlist
    new GetYouTubePlaylistAsyncTask() {
        @Override
        public EtagCache getEtagCache() {
            return mEtagCache;
        }

        @Override
        public void onPostExecute(JSONObject result) {
            handlePlaylistResult(result);
        }
    }.execute(YOUTUBE_PLAYLIST, null);

    return rootView;
}

From source file:net.idlesoft.android.apps.github.adapters.RepositoriesListAdapter.java

@Override
public View doGetView(final int index, View convertView, final ViewGroup parent) {
    ViewHolder holder;//from www.j  a v a 2 s  . co  m
    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.repository_list_item, null);
        holder = new ViewHolder();
        holder.repo_name = (TextView) convertView.findViewById(R.id.repository_list_item_name);
        holder.repo_owner = (TextView) convertView.findViewById(R.id.repository_list_item_owner);
        holder.repo_owner_label = (TextView) convertView.findViewById(R.id.repository_list_item_owner_label);
        holder.repo_description = (TextView) convertView.findViewById(R.id.repository_list_item_description);
        holder.repo_fork = (TextView) convertView.findViewById(R.id.repository_list_item_fork);
        holder.repo_watch_count = (TextView) convertView.findViewById(R.id.repository_list_item_watch_count);
        holder.repo_fork_count = (TextView) convertView.findViewById(R.id.repository_list_item_fork_count);
        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }
    try {
        final JSONObject object = (JSONObject) getData().get(index);
        String owner = "";
        owner = object.getString("owner");
        holder.repo_name.setText(object.getString("name"));
        holder.repo_owner.setText(owner);
        holder.repo_description.setText(object.getString("description"));
        holder.repo_fork_count.setText(object.getString("forks"));
        holder.repo_watch_count.setText(object.getString("watchers"));

        if (object.getBoolean("fork")) {
            holder.repo_fork.setText("(Fork) ");
        } else {
            holder.repo_fork.setText("");
        }
    } catch (final JSONException e) {
        holder.repo_owner.setVisibility(View.GONE);
        holder.repo_owner_label.setVisibility(View.GONE);
        holder.repo_description.setVisibility(View.GONE);
    }
    return convertView;
}

From source file:com.ateam.alleneatonautorentals.SalesViewCheckedOutCars.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.view_reservations);

    Intent getIntent = getIntent();//from w w w  .  j  a  v a2 s .c  o  m
    userEmail = getIntent.getStringExtra("email");
    key = getIntent.getStringExtra("key");
    name = getIntent.getStringExtra("name");

    resList = new ArrayList<HashMap<String, String>>();

    new LoadAllUserRes().execute();

    ListView lv = getListView();

    lv.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            String gps = ((TextView) view.findViewById(R.id.carres_GPS_list)).getText().toString();
            String child_seat = ((TextView) view.findViewById(R.id.carres_child_seat_list)).getText()
                    .toString();
            String k_tag = ((TextView) view.findViewById(R.id.carres_k_tag_list)).getText().toString();
            String assistance = ((TextView) view.findViewById(R.id.carres_assistance_list)).getText()
                    .toString();
            String dinsurance = ((TextView) view.findViewById(R.id.carres_dinsurance_list)).getText()
                    .toString();
            String ainsurance = ((TextView) view.findViewById(R.id.carres_ainsurance_list)).getText()
                    .toString();
            String state = ((TextView) view.findViewById(R.id.carres_state_list)).getText().toString();
            String city = ((TextView) view.findViewById(R.id.carres_city_list)).getText().toString();
            String start_date = ((TextView) view.findViewById(R.id.carres_start_list)).getText().toString();
            String end_date = ((TextView) view.findViewById(R.id.carres_end_list)).getText().toString();
            String carid = ((TextView) view.findViewById(R.id.carres_id_list)).getText().toString();
            String cartype = ((TextView) view.findViewById(R.id.carres_type_list)).getText().toString();

            Intent ii = new Intent(getApplicationContext(), SalesCheckinCar.class);

            ii.putExtra("carid", carid);
            ii.putExtra("cartype", cartype);
            ii.putExtra("state", state);
            ii.putExtra("city", city);
            ii.putExtra("start_date", start_date);
            ii.putExtra("end_date", end_date);
            ii.putExtra("gps", gps);
            ii.putExtra("child_seat", child_seat);
            ii.putExtra("ktag", k_tag);
            ii.putExtra("assistance", assistance);
            ii.putExtra("dinsurance", dinsurance);
            ii.putExtra("ainsurance", ainsurance);
            ii.putExtra("reservation", "1");
            ii.putExtra("email", userEmail);
            ii.putExtra("key", key);
            ii.putExtra("name", name);

            startActivity(ii);
            finish();
        }

    });
}

From source file:com.clearner.youtube.YouTubeFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    Picasso.with(getActivity()).setDebugging(true);

    View rootView = inflater.inflate(R.layout.youtube_fragment, container, false);

    mListView = (ListView) rootView.findViewById(R.id.youtube_listview);

    // restore the playlist after an orientation change
    /* if (savedInstanceState != null) {
    mPlaylist = new Gson().fromJson(savedInstanceState.getString(PLAYLIST_KEY), Playlist.class);
     }/*from ww w .  j  a v  a2  s.  c  o m*/
    */
    // ensure the adapter and listview are initialized
    if (mPlaylist != null) {
        initListAdapter(mPlaylist);
    }

    // start loading the first page of our playlist
    new GetYouTubePlaylistAsyncTask() {
        @Override
        public EtagCache getEtagCache() {
            return mEtagCache;
        }

        @Override
        public void onPostExecute(JSONObject result) {
            handlePlaylistResult(result);
        }
    }.execute(PLAYLIST_KEY, null);

    return rootView;
}

From source file:com.miuidev.themebrowser.MainActivity.java

private void displayAbout() {
    AlertDialog.Builder builder;//  w w  w.j  a v  a 2  s .  co  m
    AlertDialog alertDialog;

    LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
    View layout = inflater.inflate(R.layout.dialog_about,
            (ViewGroup) findViewById(R.id.DialogAboutRelativeLayout));

    TextView text = (TextView) layout.findViewById(R.id.AboutVersionValue);
    text.setText(getVersionName());

    builder = new AlertDialog.Builder(this);
    builder.setView(layout);
    builder.setCancelable(false).setPositiveButton(getString(R.string.ok),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.dismiss();
                }
            });
    alertDialog = builder.create();
    alertDialog.show();

}

From source file:com.keithandthegirl.ui.activity.FeedbackDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Log.v(TAG, "onCreateDialog : enter");

    View v = getActivity().getLayoutInflater().inflate(R.layout.fragment_feedback, null);

    editName = (EditText) v.findViewById(R.id.feedback_name);
    editLocation = (EditText) v.findViewById(R.id.feedback_location);
    editComment = (EditText) v.findViewById(R.id.feedback_comment);

    SharedPreferences sharedPreferences = getActivity().getPreferences(Context.MODE_PRIVATE);
    String name = sharedPreferences.getString(NAME_KEY, "");
    String location = sharedPreferences.getString(LOCATION_KEY, "");

    editName.setText(name);//from w w w  . jav  a2  s .  c  o m
    editLocation.setText(location);

    Log.v(TAG, "onCreateDialog : exit");
    return new AlertDialog.Builder(getActivity()).setView(v).setIcon(android.R.drawable.ic_dialog_info)
            .setTitle(getResources().getString(R.string.feedback_title))
            .setPositiveButton(R.string.feedback_positive_button, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {

                    String name = editName.getText().toString();
                    if (null != name && !"".equals(name)) {
                        name = name.trim();

                        if (name.length() > 50) {
                            name = name.substring(0, 50);
                        }
                    }

                    String location = editLocation.getText().toString();
                    if (null != location && !"".equals(location)) {
                        location = location.trim();

                        if (location.length() > 50) {
                            location = location.substring(0, 50);
                        }
                    }

                    String comment = editComment.getText().toString();
                    if (null != comment && !"".equals(comment)) {
                        comment = comment.trim();

                        if (comment.length() > 512) {
                            comment = comment.substring(0, 512);
                        }
                    }

                    savePreferences(NAME_KEY, name);
                    savePreferences(LOCATION_KEY, location);

                    if (null != comment && !"".equals(comment)) {
                        new PostCommentTask().execute(name, location, comment);
                    }

                    editComment.setText("");

                }
            }).setNegativeButton(R.string.feedback_negative_button, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    getDialog().dismiss();
                }
            }).setCancelable(true).show();
}

From source file:com.example.cuisoap.agrimac.machineRegister.machineInfoFragment.java

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_machineinfo, container, false);
    machine_name = (EditText) view.findViewById(R.id.machine_name);
    passenger_num = (EditText) view.findViewById(R.id.machine_maxpassenger);
    power = (EditText) view.findViewById(R.id.machine_power);
    wheel_distance = (EditText) view.findViewById(R.id.machine_wheeldistance);
    check_time = (EditText) view.findViewById(R.id.machine_checktime);
    license1 = (Button) view.findViewById(R.id.machine_licence_button1);
    license_pic1 = (ImageView) view.findViewById(R.id.machine_licence_pic1);
    license2 = (Button) view.findViewById(R.id.machine_licence_button2);
    license_pic2 = (ImageView) view.findViewById(R.id.machine_licence_pic2);
    machine_type = (TextView) view.findViewById(R.id.machine_type);
    pay_type = (RadioGroup) view.findViewById(R.id.machine_paytype);
    power_type = (RadioGroup) view.findViewById(R.id.machine_powertype);
    confrim = (Button) view.findViewById(R.id.machine_confirm);

    license1.setOnClickListener(myOnClickListener);
    license2.setOnClickListener(myOnClickListener);
    confrim.setOnClickListener(myOnClickListener);
    machine_type.setOnClickListener(myOnClickListener);
    return view;/*from  w  w w  . j av  a2 s.com*/
}

From source file:com.manning.androidhacks.hack025.ModelAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    final ViewHolder viewHolder;

    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.row_layout, parent, false);

        viewHolder = new ViewHolder();
        viewHolder.imageView = (ImageView) convertView.findViewById(R.id.image);
        viewHolder.text1 = (TextView) convertView.findViewById(R.id.text1);
        viewHolder.text2 = (TextView) convertView.findViewById(R.id.text2);

        convertView.setTag(viewHolder);//from w ww. ja va  2 s.c  om

    } else {
        viewHolder = (ViewHolder) convertView.getTag();
    }

    Model model = getItem(position);
    viewHolder.imageView.setImageResource(model.getImage());
    viewHolder.text1.setText(model.getText1());
    viewHolder.text2.setText(model.getText2());

    return convertView;
}