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.example.android.popularmovies.app.MoviesFragment.java

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

    movieAdapter = new MovieAdapter(getActivity(), movieArray);

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

    GridView gridView = (GridView) rootView.findViewById(R.id.gridview_movie);
    gridView.setAdapter(movieAdapter);//from   w  w w.j a va  2 s  . c  o  m

    // gridView.setColumnWidth(Integer.parseInt(getString(R.string.tmdb_image_size_342)));

    gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
            Movie movie = movieAdapter.getItem(position);
            Intent intent = new Intent(getActivity(), DetailsActivity.class);
            intent.putExtra("movie", movie);
            startActivity(intent);
        }
    });

    return rootView;
}

From source file:com.example.run_tracker.ProfileFragment.java

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

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

    mSubmit = (Button) rootView.findViewById(R.id.submit);
    mUsername = (EditText) rootView.findViewById(R.id.username);
    mPassword1 = (EditText) rootView.findViewById(R.id.newpassword1);
    mPassword2 = (EditText) rootView.findViewById(R.id.newpassword2);
    mName = (EditText) rootView.findViewById(R.id.name);
    mSurname = (EditText) rootView.findViewById(R.id.surname);
    mSubmit.setOnClickListener(this);
    mUsername.setEnabled(false);/* w  ww .  j ava 2  s  .com*/
    Make_get_profile_request();

    return rootView;

}

From source file:com.droidstore.reparline.fragments.PostFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    // Nuevo Elemento: Swipe Refresh Layout
    swipeRefresh = (SwipeRefreshLayout) view.findViewById(R.id.swipeRefreshLayout2);
    swipeRefresh.setOnRefreshListener(this);

    swipeRefresh.setColorScheme(R.color.blueReparline, R.color.redReparline, R.color.greenReparline,
            R.color.yellowReparline);//from ww w .j  av a  2 s  .  c om
}

From source file:com.linkedin.android.eventsapp.ProfileActivity.java

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

    Bundle extras = getIntent() != null ? getIntent().getExtras() : new Bundle();
    final Person person = extras.getParcelable("person");
    final Activity currentActivity = this;
    final ActionBar bar = getActionBar();
    View viewActionBar = getLayoutInflater().inflate(R.layout.layout_action_bar, null);

    ImageView backView = (ImageView) viewActionBar.findViewById(R.id.actionbar_left);
    backView.setImageResource(R.drawable.arrow_left);
    backView.setVisibility(View.VISIBLE);
    backView.setClickable(true);/*  w ww .ja v a 2  s  .co m*/
    backView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            currentActivity.finish();
        }
    });

    ActionBar.LayoutParams params = new ActionBar.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT,
            ActionBar.LayoutParams.MATCH_PARENT);
    bar.setCustomView(viewActionBar, params);
    bar.setDisplayShowCustomEnabled(true);
    bar.setDisplayShowTitleEnabled(false);
    bar.setIcon(new ColorDrawable(Color.TRANSPARENT));
    bar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#F15153")));

    TextView attendeeNameView = (TextView) findViewById(R.id.attendeeName);
    attendeeNameView.setText(person.getFirstName() + " " + person.getLastName());

    final ImageView attendeeImageView = (ImageView) findViewById(R.id.attendeeImage);
    final TextView attendeeHeadlineView = (TextView) findViewById(R.id.attendeeHeadline);
    final TextView attendeeLocationView = (TextView) findViewById(R.id.attendeeLocation);

    boolean isAccessTokenValid = LISessionManager.getInstance(currentActivity).getSession().isValid();
    if (isAccessTokenValid) {
        String url = Constants.personByIdBaseUrl + person.getLinkedinId() + Constants.personProjection;
        APIHelper.getInstance(currentActivity).getRequest(currentActivity, url, new ApiListener() {
            @Override
            public void onApiSuccess(ApiResponse apiResponse) {
                try {
                    JSONObject s = apiResponse.getResponseDataAsJson();
                    String headline = s.has("headline") ? s.getString("headline") : "";
                    String pictureUrl = s.has("pictureUrl") ? s.getString("pictureUrl") : null;
                    JSONObject location = s.getJSONObject("location");
                    String locationName = location != null && location.has("name") ? location.getString("name")
                            : "";

                    attendeeHeadlineView.setText(headline);
                    attendeeLocationView.setText(locationName);
                    if (pictureUrl != null) {
                        new FetchImageTask(attendeeImageView).execute(pictureUrl);
                    } else {
                        attendeeImageView.setImageResource(R.drawable.ghost_person);
                    }
                } catch (JSONException e) {

                }

            }

            @Override
            public void onApiError(LIApiError apiError) {

            }
        });

        ViewStub viewOnLIStub = (ViewStub) findViewById(R.id.viewOnLIStub);
        View viewOnLI = viewOnLIStub.inflate();
        Button viewOnLIButton = (Button) viewOnLI.findViewById(R.id.viewOnLinkedInButton);
        viewOnLIButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                DeepLinkHelper.getInstance().openOtherProfile(currentActivity, person.getLinkedinId(),
                        new DeepLinkListener() {
                            @Override
                            public void onDeepLinkSuccess() {

                            }

                            @Override
                            public void onDeepLinkError(LIDeepLinkError error) {

                            }
                        });
            }
        });
    } else {
        attendeeImageView.setImageResource(R.drawable.ghost_person);
    }
}

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

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (savedInstanceState != null && savedInstanceState.containsKey("cid") && cid == -1) {
        cid = savedInstanceState.getInt("cid");
        bid = savedInstanceState.getInt("bid");
    }/*from  w  w w.  ja  v a2s.  c o  m*/
    Context ctx = getActivity();
    if (ctx == null)
        return null;
    LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflater.inflate(R.layout.dialog_channel_options, null);
    members = (SwitchCompat) v.findViewById(R.id.members);
    unread = (SwitchCompat) v.findViewById(R.id.unread);
    notifyAll = (SwitchCompat) v.findViewById(R.id.notifyAll);
    joinpart = (SwitchCompat) v.findViewById(R.id.joinpart);
    collapse = (SwitchCompat) v.findViewById(R.id.collapse);
    autosuggest = (SwitchCompat) v.findViewById(R.id.autosuggest);

    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();
}

From source file:runtmobile.udea.edu.co.runtmobile.Capture.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.capture, container, false);
    surfaceView = (SurfaceView) v.findViewById(R.id.surface);
    tabHost = (FragmentTabHost) getActivity().findViewById(android.R.id.tabhost);
    // Configuracion del surface para colocarle la camara
    surfaceHolder = surfaceView.getHolder();
    surfaceHolder.addCallback(this);
    surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

    takePicture = (ImageButton) v.findViewById(R.id.buttonCam);
    // Evento del boton para tomar la foto
    takePicture.setOnClickListener(new OnClickListener() {
        @Override/*from   w w w . ja  v a 2s .c o m*/
        public void onClick(View v) {
            camera.takePicture(shutterCallback, pictureCallback, pictureJPEG);
        }
    });
    return v;
}

From source file:zjut.soft.finalwork.fragment.LeftFragment.java

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.left, null);

    iv1 = (ImageView) view.findViewById(R.id.left_iv1);
    iv2 = (ImageView) view.findViewById(R.id.left_iv2);
    iv3 = (ImageView) view.findViewById(R.id.left_iv3);
    iv4 = (ImageView) view.findViewById(R.id.left_iv4);
    iv5 = (ImageView) view.findViewById(R.id.left_iv5);
    headTV = (ImageView) view.findViewById(R.id.sliding_activity_head_view);
    headTV.setOnClickListener(new View.OnClickListener() {

        @Override//from  w  w w  . j a va 2s. co  m
        public void onClick(View v) {
            Intent i = new Intent(getActivity(), BasicInfoUI.class);
            i.putExtra("myportrait", portraitBitmap);
            getActivity().startActivity(i);
            getActivity().overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
        }
    });
    TextView tv = (TextView) view.findViewById(R.id.sliding_activity_name_tv);
    YCApplication app = (YCApplication) this.getActivity().getApplication();
    tv.setText(app.get("name").toString()); // 
    //      portrait = (ImageView) view.findViewById(R.id.sliding_activity_head_view);

    final String url = ((YCApplication) getActivity().getApplication()).get("selectedIp")
            + Constant.portraitContext;

    new Thread(new Runnable() {

        @Override
        public void run() {
            HttpGet get = new HttpGet(url);

            try {
                DefaultHttpClient client = ((YCApplication) getActivity().getApplicationContext()).getClient();
                synchronized (client) {
                    HttpResponse response = client.execute(get);
                    HttpEntity entity = response.getEntity();
                    InputStream is = entity.getContent();

                    portraitBitmap = BitmapFactory.decodeStream(is); // 
                    is.close();
                    Message msg = mHandler.obtainMessage();
                    msg.obj = portraitBitmap;
                    mHandler.sendMessage(msg);
                }

            } catch (ClientProtocolException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }

        }
    }).start();

    TextView username = (TextView) view.findViewById(R.id.sliding_activity_username_textview);
    username.setText(app.get("username").toString()); // 
    userConfTV = (TextView) view.findViewById(R.id.sliding_activity_user_manage); // 
    payQueryTV = (TextView) view.findViewById(R.id.sliding_activity_pay_query); // 
    querySystemTV = (TextView) view.findViewById(R.id.sliding_activity_query_system); // 
    aboutUsTV = (TextView) view.findViewById(R.id.sliding_activity_about_us); // 
    unRegisterTV = (TextView) view.findViewById(R.id.sliding_activity_unregister_user); // 
    classNameTV = (TextView) view.findViewById(R.id.sliding_activity_class_tv); // 

    registTV = (TextView) view.findViewById(R.id.sliding_activity_regist_system); // 
    pickCourseTV = (TextView) view.findViewById(R.id.sliding_activity_pick_course_system); // 
    RatingTV = (TextView) view.findViewById(R.id.sliding_activity_student_rating); // 
    return view;
}

From source file:com.naman14.algovisualizer.AlgoDescriptionFragment.java

private void addDescData(String algorithmKey) {
    if (descJson == null || descObject == null || getActivity() == null) {
        return;//from   www.  j  av  a2 s .co  m
    }
    rootView.removeAllViews();
    try {
        JSONObject dataObject = descObject.getJSONObject(algorithmKey);

        Iterator<?> keys = dataObject.keys();

        while (keys.hasNext()) {

            View descView = LayoutInflater.from(getActivity()).inflate(R.layout.item_code_desc, rootView,
                    false);
            TextView title = (TextView) descView.findViewById(R.id.title);
            TextView desc = (TextView) descView.findViewById(R.id.desc);
            desc.setMovementMethod(LinkMovementMethod.getInstance());

            String key = (String) keys.next();
            title.setText(key);

            if (dataObject.get(key) instanceof JSONObject) {
                JSONObject jsonObject = dataObject.getJSONObject(key);
                String descString = "";

                Iterator<?> complexityKeys = jsonObject.keys();

                while (complexityKeys.hasNext()) {
                    String complexityKey = (String) complexityKeys.next();
                    descString += " - ";
                    descString += complexityKey;
                    descString += " : ";
                    descString += jsonObject.getString(complexityKey);
                    descString += "<br>";
                }
                desc.setText(Html.fromHtml(descString));

            } else if (dataObject.get(key) instanceof JSONArray) {
                JSONArray array = dataObject.getJSONArray(key);
                String descString = "";

                for (int i = 0; i < array.length(); i++) {
                    descString += " - ";
                    descString += array.getString(i);
                    descString += "<br>";
                }
                desc.setText(Html.fromHtml(descString));

            } else if (dataObject.get(key) instanceof String) {
                desc.setText(Html.fromHtml(dataObject.getString(key)));
            }

            rootView.addView(descView);
        }

    } catch (Exception e) {
        e.printStackTrace();
    }

}

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

protected void initializeAnswerViews(View view) {
    this.signAnswerTextView = (TextView) view.findViewById(R.id.signTrainerAnswer);
    this.signMnemonicTextView = (TextView) view.findViewById(R.id.signTrainerMnemonic);
    this.signLearningProgressTextView = (TextView) view.findViewById(R.id.signTrainerLearningProgress);
    this.signHowHardWasQuestionTextView = (TextView) view.findViewById(R.id.signTrainerHowHardWasTheQuestion);
    this.signTrainerExplanationTextView = (TextView) view.findViewById(R.id.signTrainerExplanation);
    this.questionWasEasyButton = (Button) view.findViewById(R.id.signTrainerEasyButton);
    this.questionWasEasyButton.setOnClickListener(new View.OnClickListener() {
        @Override//from  w  w w.  j  a v a2 s . c  o  m
        public void onClick(View v) {
            handleClickOnQuestionWasEasyButton();
        }
    });
    this.questionWasFairButton = (Button) view.findViewById(R.id.signTrainerFairButton);
    this.questionWasFairButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            handleClickOnQuestionWasFairButton();
        }
    });
    this.questionWasHardButton = (Button) view.findViewById(R.id.signTrainerHardButton);
    this.questionWasHardButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            handleClickOnQuestionWasHardButton();
        }
    });
}

From source file:com.yangtsaosoftware.pebblemessenger.activities.AppListPreference.java

@Override
protected void onBindDialogView(@NonNull View view) {
    lvPackageInfo = (ListView) view.findViewById(R.id.listView);
    pbInworking = (ProgressBar) view.findViewById(R.id.progressBar);
    new LoadAppsTask().execute(LoadAppsTask.SORT_BY_NAME);
    super.onBindDialogView(view);
}