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.manning.androidhacks.hack026.SectionAdapter.java

@Override
public View getView(int position, View view, ViewGroup parent) {
    if (view == null) {
        view = activity.getLayoutInflater().inflate(R.layout.list_item, parent, false);
    }/*from   w w  w. j  a  va 2s.c  o  m*/
    TextView header = (TextView) view.findViewById(R.id.header);
    String label = getItem(position);
    if (position == 0 || getItem(position - 1).charAt(0) != label.charAt(0)) {
        header.setVisibility(View.VISIBLE);
        header.setText(label.substring(0, 1));
    } else {
        header.setVisibility(View.GONE);
    }
    return super.getView(position, view, parent);
}

From source file:com.gammalabs.wifianalyzer.wifi.AccessPointDetail.java

private void setViewCompact(@NonNull Context context, @NonNull View view, @NonNull WiFiDetail wiFiDetail,
        boolean isChild) {
    ((TextView) view.findViewById(R.id.ssid)).setText(wiFiDetail.getTitle());

    WiFiSignal wiFiSignal = wiFiDetail.getWiFiSignal();
    Strength strength = wiFiSignal.getStrength();

    Security security = wiFiDetail.getSecurity();
    ImageView securityImage = (ImageView) view.findViewById(R.id.securityImage);
    securityImage.setImageResource(security.imageResource());
    securityImage.setColorFilter(ContextCompat.getColor(context, R.color.icons_color));

    TextView textLevel = (TextView) view.findViewById(R.id.level);
    textLevel.setText(String.format(Locale.ENGLISH, "%ddBm", wiFiSignal.getLevel()));
    textLevel.setTextColor(ContextCompat.getColor(context, strength.colorResource()));

    ((TextView) view.findViewById(R.id.channel)).setText(wiFiSignal.getChannelDisplay());
    ((TextView) view.findViewById(R.id.primaryFrequency)).setText(String.format(Locale.ENGLISH, "%d%s",
            wiFiSignal.getPrimaryFrequency(), WiFiSignal.FREQUENCY_UNITS));
    ((TextView) view.findViewById(R.id.distance))
            .setText(String.format(Locale.ENGLISH, "%5.1fm", wiFiSignal.getDistance()));

    if (isChild) {
        view.findViewById(R.id.tab).setVisibility(View.VISIBLE);
    } else {//from   ww w.  j a  va2s .  c om
        view.findViewById(R.id.tab).setVisibility(View.GONE);
    }
}

From source file:com.royclarkson.springagram.GalleryAddFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_gallery_add, container, false);
    Button button = (Button) view.findViewById(R.id.button_save);
    button.setOnClickListener(this);
    return view;/*  w  ww.j  a va 2  s  . c  o  m*/
}

From source file:org.kepennar.android.client.social.facebook.FacebookFeedListAdapter.java

public View getView(int position, View convertView, ViewGroup parent) {
    Post entry = getItem(position);//from   w w  w  .  java  2  s . c  o  m

    View view = convertView;

    if (view == null) {
        view = _layoutInflater.inflate(R.layout.facebook_feed_list_item, parent, false);
    }

    TextView t = (TextView) view.findViewById(R.id.from_name);
    t.setText(entry.getFrom().getName());

    t = (TextView) view.findViewById(R.id.updated_time);
    t.setText(entry.getUpdatedTime().toString());

    t = (TextView) view.findViewById(R.id.message);
    t.setText(entry.getMessage());

    return view;
}

From source file:com.mikecorrigan.trainscorekeeper.FragmentHistory.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log.vc(VERBOSE, TAG, "onCreateView: inflater=" + inflater + ", container=" + container
            + ", savedInstanceState=" + Utils.bundleToString(savedInstanceState));

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

    textView = (TextView) rootView.findViewById(R.id.text_view_history);
    scrollView = (ScrollView) rootView.findViewById(R.id.scroll_view);

    // Get the model and attach a listener.
    MainActivity activity = (MainActivity) getActivity();
    game = activity.getGame();//from   ww w  .  j a  v  a 2 s  . co  m
    if (game != null) {
        game.addListener(mGameListener);
    }

    Bundle args = getArguments();
    if (args == null) {
        Log.e(TAG, "onCreateView: missing arguments");
        return rootView;
    }

    // final int index = args.getInt(ARG_INDEX);
    // final String tabSpec = args.getString(ARG_TAB_SPEC);

    return rootView;
}

From source file:com.perm.DoomPlay.AddTrackToAlbumDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    trackId = getArguments().getLong(keyDialogAlbum);
    getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);

    View view = inflater.inflate(R.layout.list_vk, container, false);
    linearLoading = (LinearLayout) view.findViewById(R.id.linearLoading);
    listView = (ListView) view.findViewById(R.id.listVk);
    listView.setOnItemClickListener(onItemClickHandler);

    return view;/*w w w.j av a 2 s.  c  o m*/
}

From source file:cn.newgxu.android.bbs.ui.UserFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.user, container, false);
    powers = (Button) v.findViewById(R.id.powers);
    sex_and_qq = (Button) v.findViewById(R.id.sex_and_qq);
    desc = (Button) v.findViewById(R.id.desc);
    exp_and_xdb = (Button) v.findViewById(R.id.exp_and_xdb);
    nick = (Button) v.findViewById(R.id.nick);
    title_and_register_time = (Button) v.findViewById(R.id.title_and_register_time);
    statistics = (Button) v.findViewById(R.id.statistics);
    honors = (Button) v.findViewById(R.id.honors);
    icon = (ImageView) v.findViewById(R.id.icon);
    return v;/*from   w  w  w. ja  v a  2  s .c o  m*/
}

From source file:com.vrem.wifianalyzer.wifi.accesspoint.AccessPointDetail.java

private void setViewCompact(@NonNull Context context, @NonNull View view, @NonNull WiFiDetail wiFiDetail,
        boolean isChild) {
    ((TextView) view.findViewById(R.id.ssid)).setText(wiFiDetail.getTitle());

    WiFiSignal wiFiSignal = wiFiDetail.getWiFiSignal();
    Strength strength = wiFiSignal.getStrength();

    Security security = wiFiDetail.getSecurity();
    ImageView securityImage = (ImageView) view.findViewById(R.id.securityImage);
    securityImage.setImageResource(security.getImageResource());
    securityImage.setColorFilter(ContextCompat.getColor(context, R.color.icons_color));

    TextView textLevel = (TextView) view.findViewById(R.id.level);
    textLevel.setText(String.format(Locale.ENGLISH, "%ddBm", wiFiSignal.getLevel()));
    textLevel.setTextColor(ContextCompat.getColor(context, strength.colorResource()));

    ((TextView) view.findViewById(R.id.channel)).setText(wiFiSignal.getChannelDisplay());
    ((TextView) view.findViewById(R.id.primaryFrequency)).setText(String.format(Locale.ENGLISH, "%d%s",
            wiFiSignal.getPrimaryFrequency(), WiFiSignal.FREQUENCY_UNITS));
    ((TextView) view.findViewById(R.id.distance))
            .setText(String.format(Locale.ENGLISH, "%5.1fm", wiFiSignal.getDistance()));

    if (isChild) {
        view.findViewById(R.id.tab).setVisibility(View.VISIBLE);
    } else {/*from  w  w  w .j  a  v a2  s.c  o  m*/
        view.findViewById(R.id.tab).setVisibility(View.GONE);
    }
}

From source file:de.wikilab.android.friendica01.Max.java

/**
 * displays the login form (layout/loginscreen.xml) as a modal dialog and calls tryLogin
  * when user confirms the form/*w ww . j a  va 2 s . c  om*/
 * @param ctx     MUST IMPLEMENT LoginListener !!!
 * @param errmes  message which is displayed above the Login form (e.g. "wrong password entered")
 */
public static void showLoginForm(final Activity ctx, String errmes) {
    Log.v(TAG, "... showLoginForm");
    View myView = ctx.getLayoutInflater().inflate(R.layout.loginscreen, null, false);
    final AlertDialog alert = new AlertDialog.Builder(ctx).setTitle("Login to Friendica").setView(myView)
            .setOnCancelListener(new OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialog) {
                    ctx.finish();
                }
            }).show();

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx);
    String protocol = prefs.getString("login_protocol", "https");
    String server = prefs.getString("login_server", null);
    String userName = prefs.getString("login_user", null);

    if (errmes != null) {
        ((TextView) myView.findViewById(R.id.lblInfo)).setText(errmes);
    }

    final Spinner selProtocol = (Spinner) myView.findViewById(R.id.selProtocol);
    selProtocol.setSelection(protocol.equals("https") ? 1 : 0); //HACK !!!

    final EditText edtServer = (EditText) myView.findViewById(R.id.edtServer);
    edtServer.setText(server);

    final EditText edtUser = (EditText) myView.findViewById(R.id.edtUser);
    edtUser.setText(userName);

    final EditText edtPassword = (EditText) myView.findViewById(R.id.edtPassword);

    ((TextView) myView.findViewById(R.id.proxy_settings)).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ctx.startActivity(new Intent(ctx, PreferencesActivity.class));
        }
    });

    ((Button) myView.findViewById(R.id.button1)).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            SharedPreferences.Editor prefs = PreferenceManager.getDefaultSharedPreferences(ctx).edit();
            prefs.putString("login_protocol", selProtocol.getSelectedItem().toString());
            String server = edtServer.getText().toString();
            server = server.replaceAll("^https?://", "");
            prefs.putString("login_server", server);
            prefs.putString("login_user", edtUser.getText().toString());
            prefs.putString("login_password", edtPassword.getText().toString());
            prefs.commit();

            alert.dismiss();

            tryLogin(ctx);
        }
    });
}

From source file:ca.liquidlabs.android.speedtestvisualizer.fragments.SpeedTestInfoWindowAdapter.java

/**
 * Renders marker contents into the infobox
 * /*from  w  ww.  j  av a2  s .  c o m*/
 * @param marker Map marker
 * @param view Custom infobox view
 */
private void renderContents(Marker marker, View view) {
    String[] snippetInfo = StringUtils.split(marker.getSnippet(), AppConstants.TEXT_SEPARATOR);

    TextView infoHeading = (TextView) view.findViewById(R.id.txt_info_heading);
    infoHeading.setText("@ " + marker.getTitle());

    TextView downloadSpeed = (TextView) view.findViewById(R.id.txt_info_download);
    downloadSpeed.setText(snippetInfo[1]);

    TextView uploadSpeed = (TextView) view.findViewById(R.id.txt_info_upload);
    uploadSpeed.setText(snippetInfo[2]);

    // Connection type - update image based on type
    ConnectionType connType = ConnectionType.fromString(snippetInfo[0]);
    ImageView conntypeImage = (ImageView) view.findViewById(R.id.img_legend_conntype);
    if (connType.isWifi()) {
        conntypeImage.setImageResource(R.drawable.ic_connection_wifi);
    } else {
        conntypeImage.setImageResource(R.drawable.ic_connection_cell);
    }
    TextView connTypeTxt = (TextView) view.findViewById(R.id.txt_info_conntype);
    connTypeTxt.setText(snippetInfo[0]);
}