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.wbs.itm.AllEventsActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.all_events);
    // Hashmap for ListView
    NoticesList = new ArrayList<HashMap<String, String>>();
    // Loading notices in Background Thread
    new LoadAllNotices().execute();
    // Get listview
    ListView lv = getListView();/*ww  w.ja  v  a2  s .  co m*/
    // on seleting single item
    lv.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // getting values from selected ListItem
            String pid = ((TextView) view.findViewById(R.id.einfo)).getText().toString();
            // Starting new intent
            Intent in = new Intent(getApplicationContext(), DownloadManager.class);
            // sending pid to next activity
            in.putExtra("pathid", pid);
            // starting new activity and expecting some response back
            startActivityForResult(in, 100);
        }
    });
}

From source file:de.lebenshilfe_muenster.uk_gebaerden_muensterland.sign_trainer.SignTrainerActiveFragment.java

@Nullable
@Override// ww  w.  j ava  2 s.  c  o m
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log.d(TAG, "onCreateView " + hashCode());
    final View view = inflater.inflate(R.layout.trainer_active_fragment, container, false);
    setHasOptionsMenu(true);
    initializeQuestionViews(view);
    this.signQuestionTextDetail = (TextView) view.findViewById(R.id.signTrainerQuestionTextDetail);
    initializeAnswerViews(view);
    initializeVideoViews(view);
    this.questionViews = new View[] { this.signQuestionText, this.signQuestionTextDetail,
            this.solveQuestionButton };
    this.answerViews = new View[] { this.signAnswerTextView, this.videoView, this.signMnemonicTextView,
            this.signLearningProgressTextView, this.signHowHardWasQuestionTextView,
            this.signTrainerExplanationTextView, this.questionWasEasyButton, this.questionWasFairButton,
            this.questionWasHardButton };
    setVisibility(this.questionViews, View.VISIBLE);
    setVisibility(this.answerViews, View.GONE);
    return view;
}

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

public View getView(final int index, View convertView, final ViewGroup parent) {
    ViewHolder holder;/*from   w  w w .  j  a v  a 2  s . co  m*/
    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.branch_list_item, null);
        holder = new ViewHolder();
        holder.text = (TextView) convertView.findViewById(R.id.tv_branchListItem_branchName);
        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }
    try {
        holder.text.setText(mJson.names().getString(index));
    } catch (final JSONException e) {
        e.printStackTrace();
    }
    return convertView;
}

From source file:com.github.notizklotz.derbunddownloader.issuesgrid.DownloadedIssuesActivity.java

@AfterViews
void setupIssuesGrid() {
    gridView.setEmptyView(emptyGridView);
    gridView.setOnItemClickListener(new IssuesGridOnItemClickListener());

    final SimpleCursorAdapter issueListAdapter = new SimpleCursorAdapter(this, R.layout.include_issue, null,
            new String[] { DownloadManager.COLUMN_DESCRIPTION, DownloadManager.COLUMN_STATUS },
            new int[] { R.id.dateTextView, R.id.stateTextView }, 0) {

        @Override/*from w  w  w  .j a v  a2s.  co m*/
        public View getView(final int position, View convertView, ViewGroup parent) {
            View view = super.getView(position, convertView, parent);
            View deleteButton = view.findViewById(R.id.issueDeleteButton);
            deleteButton.setOnClickListener(new IssueDeleteButtonOnClickListener(position));

            // Load the thumbnail image
            ImageView image = (ImageView) view.findViewById(R.id.issueImageView);
            Uri uri = Uri.parse(getCursor().getString(getCursor().getColumnIndex(DownloadManager.COLUMN_URI)));
            Picasso.with(image.getContext()).load(IssueDownloadService_.getThumbnailUriForPDFUri(uri))
                    .placeholder(R.drawable.issue_placeholder).into(image);
            return view;
        }
    };
    issueListAdapter.setViewBinder(new IssuesGridViewBinder(this));
    gridView.setAdapter(issueListAdapter);

    getLoaderManager().initLoader(1, null, new IssuesGridLoaderCallbacks(this, issueListAdapter));
}

From source file:com.vrem.wifianalyzer.wifi.channelrating.ChannelRatingAdapterTest.java

@Test
public void testGetView() throws Exception {
    // setup//  w  w  w. ja v a2  s.  c  o m
    int expectedSize = Strength.values().length;
    Strength expectedStrength = Strength.reverse(Strength.FOUR);
    WiFiChannel wiFiChannel = new WiFiChannel(1, 2);
    fixture.add(wiFiChannel);
    when(channelRating.getCount(wiFiChannel)).thenReturn(5);
    when(channelRating.getStrength(wiFiChannel)).thenReturn(Strength.FOUR);
    // execute
    View actual = fixture.getView(0, null, null);
    // validate
    assertNotNull(actual);

    assertEquals("1", ((TextView) actual.findViewById(R.id.channelNumber)).getText());
    assertEquals("5", ((TextView) actual.findViewById(R.id.accessPointCount)).getText());

    RatingBar ratingBar = (RatingBar) actual.findViewById(R.id.channelRating);
    assertEquals(expectedSize, ratingBar.getMax());
    assertEquals(expectedSize, ratingBar.getNumStars());
    assertEquals(expectedStrength.ordinal() + 1, (int) ratingBar.getRating());

    assertEquals("", bestChannels.getText());

    verify(channelRating).getCount(wiFiChannel);
    verify(channelRating).getStrength(wiFiChannel);
}

From source file:com.dattasmoon.pebble.plugin.ConvertPreference.java

@Override
protected void onBindDialogView(View view) {
    Button btnAdd = (Button) view.findViewById(R.id.btnAdd);
    etFrom = (EditText) view.findViewById(R.id.etFrom);
    etTo = (EditText) view.findViewById(R.id.etTo);
    lvConvert = (ListView) view.findViewById(R.id.lvConvert);
    lvConvert.setEmptyView(view.findViewById(android.R.id.empty));
    lvConvert.setAdapter(arrayAdapter);/*from  w  w  w  . j  ava 2s . c om*/
    lvConvert.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {
        @Override
        public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) {
            AdapterView.AdapterContextMenuInfo contextInfo = (AdapterView.AdapterContextMenuInfo) menuInfo;
            int position = contextInfo.position;
            long id = contextInfo.id;
            // the child view who's info we're viewing (should be equal to v)
            View v = contextInfo.targetView;
            AlertDialog.Builder builder = new AlertDialog.Builder(v.getContext());

            final int arrayPosition = (Integer) v.getTag();
            final String text = ((TextView) v.findViewById(R.id.tvItem)).getText().toString();
            builder.setMessage(
                    getContext().getResources().getString(R.string.confirm_delete) + " '" + text + "' ?")
                    .setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            JSONArray temp = new JSONArray();
                            for (int i = 0; i < arrayAdapter.getJSONArray().length(); i++) {
                                if (i == arrayPosition) {
                                    continue;
                                }
                                try {
                                    temp.put(arrayAdapter.getJSONArray().getJSONObject(i));
                                } catch (JSONException e) {
                                    e.printStackTrace();
                                }
                            }
                            arrayAdapter.setJSONArray(temp);

                            arrayAdapter.notifyDataSetChanged();
                        }
                    }).setNegativeButton(R.string.decline, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            // User cancelled the dialog
                        }
                    });
            builder.create().show();
        }
    });

    btnAdd.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            JSONObject item = new JSONObject();
            try {
                item.put("from", etFrom.getText().toString());
                item.put("to", etTo.getText().toString());
                arrayAdapter.getJSONArray().put(item);
                etFrom.setText("");
                etTo.setText("");
                arrayAdapter.notifyDataSetChanged();
            } catch (JSONException e) {
                e.printStackTrace();
            }

        }
    });
    super.onBindDialogView(view);
}

From source file:com.mercandalli.android.apps.files.user.RegistrationFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_registration, container, false);
    this.mUsername = (EditText) rootView.findViewById(R.id.fragment_registration_username);
    this.mPassword = (EditText) rootView.findViewById(R.id.fragment_registration_password);

    ((CheckBox) rootView.findViewById(R.id.fragment_registration_auto_connection))
            .setChecked(Config.isAutoConnection());
    ((CheckBox) rootView.findViewById(R.id.fragment_registration_auto_connection))
            .setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                @Override//from   w  w w  . j av  a 2 s.c o m
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    Config.setAutoConnection(getContext(), isChecked);
                }
            });

    this.mUsername.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER))
                    || (actionId == EditorInfo.IME_ACTION_DONE)) {
                RegistrationFragment.this.mPassword.requestFocus();
                return true;
            }
            return false;
        }
    });

    this.mPassword.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER))
                    || (actionId == EditorInfo.IME_ACTION_DONE)) {
                inscription();
                return true;
            }
            return false;
        }
    });

    return rootView;
}

From source file:com.timecontents.smartnotice.animate.AnimatedListViewAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (position > _objects.size()) {
        return null;
    }//from  ww  w  . ja va2 s  .  c o  m

    View v = convertView;
    ViewHolder holder;
    if (v == null) {
        v = _inflater.inflate(_resourceId, parent, false);

        holder = new ViewHolder();
        holder.tvTitle = (TextView) v.findViewById(R.id.tv_notice_title);
        holder.tvDate = (TextView) v.findViewById(R.id.tv_notice_date);
        holder.tvContent = (LinkEllipseTextView) v.findViewById(R.id.tv_notice_content_ellipse);
        holder.imgContent = (ImageView) v.findViewById(R.id.img_notice_content);
        holder.imgFileIcon = (ImageView) v.findViewById(R.id.img_notice_file_icon);
        holder.imgType = (ImageView) v.findViewById(R.id.img_notice_type_icon); // ? ?  ?

        v.setTag(holder);
    } else
        holder = (ViewHolder) v.getTag();

    JSONObject object = _objects.get(position);
    _objectMapper.bindObjectToView(object, holder, v);

    if (v != null) {
        Animation animation = new TranslateAnimation(0, 0, (position > lastPosition) ? 100 : -100, 0);
        animation.setDuration(400);
        v.startAnimation(animation);
    }
    lastPosition = position;

    return v;
}

From source file:app.hacked.ChallengeListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.challenge_list_fragment, null);
    progressBar = view.findViewById(R.id.progressBar);
    return view;/* w w w . j a v  a 2  s  .co  m*/
}

From source file:com.irccloud.android.fragment.BufferOptionsFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Context ctx = getActivity();//from  ww w. jav a2s . c o  m
    if (ctx == null)
        return null;
    LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflater.inflate(R.layout.dialog_buffer_options, null);
    unread = (SwitchCompat) v.findViewById(R.id.unread);
    joinpart = (SwitchCompat) v.findViewById(R.id.joinpart);
    collapse = (SwitchCompat) v.findViewById(R.id.collapse);
    expandDisco = (SwitchCompat) v.findViewById(R.id.expandDisco);

    if (savedInstanceState != null && bid == -1 && savedInstanceState.containsKey("bid")) {
        bid = savedInstanceState.getInt("bid");
        cid = savedInstanceState.getInt("cid");
        type = savedInstanceState.getString("type");
    }

    if (type != null && type.equalsIgnoreCase("console")) {
        joinpart.setVisibility(View.GONE);
        collapse.setVisibility(View.GONE);
    } else {
        expandDisco.setVisibility(View.GONE);
    }

    return new AlertDialog.Builder(ctx)
            .setInverseBackgroundForced(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB)
            .setTitle("Display Options").setView(v).setPositiveButton("Save", new SaveClickListener())
            .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            }).create();
}