Example usage for android.view ViewGroup findViewById

List of usage examples for android.view ViewGroup findViewById

Introduction

In this page you can find the example usage for android.view ViewGroup 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.infine.android.devoxx.ui.ScheduleFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_schedule, null);

    mWorkspace = (Workspace) root.findViewById(R.id.workspace);

    mTitle = (TextView) root.findViewById(R.id.block_title);

    mLeftIndicator = root.findViewById(R.id.indicator_left);
    mLeftIndicator.setOnTouchListener(new View.OnTouchListener() {
        public boolean onTouch(View view, MotionEvent motionEvent) {
            if ((motionEvent.getAction() & MotionEventUtils.ACTION_MASK) == MotionEvent.ACTION_DOWN) {
                mWorkspace.scrollLeft();
                return true;
            }/*from   www. j a v a  2s .c o m*/
            return false;
        }
    });
    mLeftIndicator.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            mWorkspace.scrollLeft();
        }
    });

    mRightIndicator = root.findViewById(R.id.indicator_right);
    mRightIndicator.setOnTouchListener(new View.OnTouchListener() {
        public boolean onTouch(View view, MotionEvent motionEvent) {
            if ((motionEvent.getAction() & MotionEventUtils.ACTION_MASK) == MotionEvent.ACTION_DOWN) {
                mWorkspace.scrollRight();
                return true;
            }
            return false;
        }
    });
    mRightIndicator.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            mWorkspace.scrollRight();
        }
    });

    // creation des jours
    for (long day : eventDays) {
        setupDay(inflater, day);
    }
    // setupDay(inflater, TUE_START);
    // setupDay(inflater, WED_START);

    updateWorkspaceHeader(0);
    mWorkspace.setOnScrollListener(new Workspace.OnScrollListener() {
        public void onScroll(float screenFraction) {
            updateWorkspaceHeader(Math.round(screenFraction));
        }
    }, true);

    //      mWorkspace.setDrawingCacheEnabled(false);
    //      mLeftIndicator.setDrawingCacheEnabled(false);
    //      mRightIndicator.setDrawingCacheEnabled(false);
    ////      mWorkspace.setDrawingCacheEnabled(false);
    ////      mWorkspace.setDrawingCacheEnabled(false);
    ////      mWorkspace.setDrawingCacheEnabled(false);
    //      for(Day day : mDays){
    //         day.rootView.setDrawingCacheEnabled(false);
    //         day.scrollView.setDrawingCacheEnabled(false);
    //      }

    return root;
}

From source file:gov.wa.wsdot.android.wsdot.ui.ferries.departures.FerriesRouteSchedulesDayDeparturesFragment.java

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

    tf = Typeface.createFromAsset(getActivity().getAssets(), "fonts/Roboto-Regular.ttf");
    tfb = Typeface.createFromAsset(getActivity().getAssets(), "fonts/Roboto-Bold.ttf");

    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_route_schedules_day_departures, null);

    mRecyclerView = root.findViewById(R.id.my_recycler_view);
    mLayoutManager = new LinearLayoutManager(getActivity());
    mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    mRecyclerView.setLayoutManager(mLayoutManager);
    mAdapter = new DepartureTimesAdapter(getActivity(), null);

    mRecyclerView.setAdapter(mAdapter);/*from ww  w  .  j  a va  2 s .  co m*/

    mRecyclerView.addItemDecoration(new SimpleDividerItemDecoration(getActivity()));

    // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are
    // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity.
    root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    swipeRefreshLayout = root.findViewById(R.id.swipe_container);
    swipeRefreshLayout.setOnRefreshListener(this);
    swipeRefreshLayout.setColorSchemeResources(R.color.holo_blue_bright, R.color.holo_green_light,
            R.color.holo_orange_light, R.color.holo_red_light);

    mEmptyView = root.findViewById(R.id.empty_list_view);

    schedulesViewModel = ViewModelProviders.of(getActivity()).get(FerrySchedulesViewModel.class);

    terminalViewModel = ViewModelProviders.of(getActivity()).get(FerryTerminalViewModel.class);

    terminalViewModel.getResourceStatus().observe(this, resourceStatus -> {
        if (resourceStatus != null) {
            switch (resourceStatus.status) {
            case LOADING:
                swipeRefreshLayout.setRefreshing(true);
                break;
            case SUCCESS:
                swipeRefreshLayout.setRefreshing(false);
                break;
            case ERROR:
                swipeRefreshLayout.setRefreshing(false);
                Toast.makeText(this.getContext(), "connection error, can't update spaces", Toast.LENGTH_SHORT)
                        .show();
            }
        }
    });

    terminalViewModel.getDepartureTimes().observe(this, sailingTimes -> {

        if (sailingTimes != null) {
            if (sailingTimes.size() != 0) {
                mEmptyView.setVisibility(View.GONE);
            } else {
                TextView t = (TextView) mEmptyView;
                t.setText(R.string.no_day_departures);
                mEmptyView.setVisibility(View.VISIBLE);
            }

            mAdapter.setData(new ArrayList<>(sailingTimes));

            // Scroll to the first sailing time that hasn't already passed.
            if (terminalViewModel.getShouldScrollToCurrent()) {
                terminalViewModel.setScrollToCurrent(false);
                try {
                    Date now = new Date();
                    for (int i = 0; i < sailingTimes.size(); i++) {
                        if (now.before(sailingTimes.get(i).getDepartingTime())) {
                            mRecyclerView.stopScroll();
                            ((LinearLayoutManager) mRecyclerView.getLayoutManager())
                                    .scrollToPositionWithOffset(i, 0);
                            i = sailingTimes.size();
                        }
                    }
                } catch (Exception e) {
                    MyLogger.crashlyticsLog("Ferries", "Error", "Auto scroll failed", 1);
                }
            }
        }
    });

    terminalViewModel.getDepartureTimesAnnotations().observe(this, sailingAnnotations -> {
        if (sailingAnnotations != null) {
            annotations = new ArrayList<>(sailingAnnotations);
            mAdapter.notifyDataSetChanged();
        } else {
            annotations.clear();
        }
    });

    terminalViewModel.forceRefreshVesselStatus();

    return root;
}

From source file:com.rsmsa.accapp.ScreenSlidePageFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.vehicle_one, container, false);

    tab_one = (EditText) rootView.findViewById(R.id.dob_one);
    Log.d("vp", "current page " + MainActivity.currentPage);
    Log.d("vp", "tab text " + tab_one.getText());
    /**/*from  ww  w  .j av a  2 s. c  o  m*/
     * Defining all layout items
     **/

    inputFatal = (EditText) rootView.findViewById(R.id.fatal_edit);
    inputInjuries = (EditText) rootView.findViewById(R.id.injury_edit);
    inputSimple = (EditText) rootView.findViewById(R.id.simple_edit);
    inputNotInjured = (EditText) rootView.findViewById(R.id.not_injured_edit);

    //driver 0ne details
    surname_one = (EditText) rootView.findViewById(R.id.surname_one);
    othernames_one = (EditText) rootView.findViewById(R.id.othernames_one);
    physical_address_one = (EditText) rootView.findViewById(R.id.physical_address_one);
    address_box_one = (EditText) rootView.findViewById(R.id.address_box_one);
    national_id_one = (EditText) rootView.findViewById(R.id.national_id_one);
    phone_no_one = (EditText) rootView.findViewById(R.id.phone_no_one);
    gender = (RadioGroup) rootView.findViewById(R.id.gender);
    RadioButton male = (RadioButton) rootView.findViewById(R.id.male);
    RadioButton female = (RadioButton) rootView.findViewById(R.id.female);
    nationality_one = (EditText) rootView.findViewById(R.id.nationality_one);
    license_one = (EditText) rootView.findViewById(R.id.license_one);
    occupation_one = (EditText) rootView.findViewById(R.id.occupation_one);

    alcohol_edit = (EditText) rootView.findViewById(R.id.alcohol_edit);
    drug_edit = (CheckBox) rootView.findViewById(R.id.drug_edit);
    phone_edit = (CheckBox) rootView.findViewById(R.id.phone_edit);
    seat_belt_edit = (CheckBox) rootView.findViewById(R.id.seat_belt_edit);

    //Vehicle one details
    type_one = (EditText) rootView.findViewById(R.id.type_one);
    registration_number_one = (EditText) rootView.findViewById(R.id.registration_number_one);

    //Vehicle one  Insurance details
    company_one = (EditText) rootView.findViewById(R.id.company_one);
    insurance_type_one = (EditText) rootView.findViewById(R.id.insurance_type_one);
    insurance_phone = (EditText) rootView.findViewById(R.id.insurance_phone);
    policy_period_one = (EditText) rootView.findViewById(R.id.policy_period_one);
    policy_number_one = (EditText) rootView.findViewById(R.id.policy_number_one);
    repair_amount_one = (EditText) rootView.findViewById(R.id.repair_amount_one);

    //Vehicle one  damage details
    vehicle = (EditText) rootView.findViewById(R.id.vehicle_title_edit);
    vehicle_total = (EditText) rootView.findViewById(R.id.vehicle_total_edit);
    infrastructure = (EditText) rootView.findViewById(R.id.infrastructure_edit);
    cost = (EditText) rootView.findViewById(R.id.rescue_cost_edit);

    //Textchange
    inputFatal.addTextChangedListener(new EditTextWatcher(inputFatal));
    inputInjuries.addTextChangedListener(new EditTextWatcher(inputInjuries));
    inputSimple.addTextChangedListener(new EditTextWatcher(inputSimple));
    inputNotInjured.addTextChangedListener(new EditTextWatcher(inputNotInjured));

    surname_one.addTextChangedListener(new EditTextWatcher(surname_one));
    othernames_one.addTextChangedListener(new EditTextWatcher(othernames_one));
    physical_address_one.addTextChangedListener(new EditTextWatcher(physical_address_one));
    address_box_one.addTextChangedListener(new EditTextWatcher(address_box_one));
    national_id_one.addTextChangedListener(new EditTextWatcher(national_id_one));
    phone_no_one.addTextChangedListener(new EditTextWatcher(phone_no_one));
    inputFatal.addTextChangedListener(new EditTextWatcher(inputFatal));
    inputInjuries.addTextChangedListener(new EditTextWatcher(inputInjuries));
    inputSimple.addTextChangedListener(new EditTextWatcher(inputSimple));
    inputNotInjured.addTextChangedListener(new EditTextWatcher(inputNotInjured));
    // gender.addTextChangedListener(new EditTextWatcher(gender));
    nationality_one.addTextChangedListener(new EditTextWatcher(nationality_one));
    license_one.addTextChangedListener(new EditTextWatcher(license_one));
    occupation_one.addTextChangedListener(new EditTextWatcher(occupation_one));

    alcohol_edit.addTextChangedListener(new EditTextWatcher(alcohol_edit));
    //drug_edit.addTextChangedListener(new EditTextWatcher(drug_edit));
    //phone_edit.addTextChangedListener(new EditTextWatcher(phone_edit));
    //seat_belt_edit.addTextChangedListener(new EditTextWatcher(seat_belt_edit));

    type_one.addTextChangedListener(new EditTextWatcher(type_one));
    registration_number_one.addTextChangedListener(new EditTextWatcher(registration_number_one));

    company_one.addTextChangedListener(new EditTextWatcher(company_one));
    insurance_type_one.addTextChangedListener(new EditTextWatcher(insurance_type_one));
    insurance_phone.addTextChangedListener(new EditTextWatcher(insurance_phone));
    policy_period_one.addTextChangedListener(new EditTextWatcher(policy_period_one));
    policy_number_one.addTextChangedListener(new EditTextWatcher(policy_number_one));
    repair_amount_one.addTextChangedListener(new EditTextWatcher(repair_amount_one));

    vehicle.addTextChangedListener(new EditTextWatcher(vehicle));
    vehicle_total.addTextChangedListener(new EditTextWatcher(vehicle_total));
    infrastructure.addTextChangedListener(new EditTextWatcher(infrastructure));
    cost.addTextChangedListener(new EditTextWatcher(cost));

    vehicle_category = (Spinner) rootView.findViewById(R.id.vtype_spinner);

    vehicle_type = (Button) rootView.findViewById(R.id.vehicle_type_select_button);

    cal = Calendar.getInstance();

    day = cal.get(Calendar.DAY_OF_MONTH);

    month = cal.get(Calendar.MONTH);

    year = cal.get(Calendar.YEAR);

    pickDate = (Button) rootView.findViewById(R.id.date_picker);
    pickDate.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            DatePickerDialog datePickerDialog = new DatePickerDialog(getActivity(), datePickerListener, year,
                    month, day);
            datePickerDialog.show();
        }
    });

    List<String> vehicle_category_list = new ArrayList<String>();
    vehicle_category_list.add("Private");
    vehicle_category_list.add("Commercial");
    vehicle_category_list.add("Government");
    vehicle_category_list.add("Emergency");
    vehicle_category_list.add("Passenger Service Vehicles");

    vehicle_category.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            selectedSpinner = i;
            if (i == 0) {
                selectedSpinner = 234;
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {

        }
    });

    vehicle_type.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(getActivity(), VehicleType.class);
            intent.putExtra("category", selectedSpinner + "");
            startActivity(intent);
        }
    });

    ArrayAdapter<String> atc_adapter = new ArrayAdapter<String>(getActivity(),
            android.R.layout.simple_spinner_item, vehicle_category_list);
    atc_adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    vehicle_category.setAdapter(atc_adapter);

    return rootView;
}

From source file:com.google.android.apps.iosched2.ui.TagStreamFragment.java

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

    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_webview_with_spinner, null);

    // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are
    // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity.
    root.setLayoutParams(/*  www  .  j  a  v a  2 s  .c om*/
            new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

    mLoadingSpinner = root.findViewById(R.id.loading_spinner);
    mWebView = (WebView) root.findViewById(R.id.webview);
    mWebView.setWebViewClient(mWebViewClient);

    mWebView.post(new Runnable() {
        public void run() {
            mWebView.getSettings().setJavaScriptEnabled(true);
            mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
            try {
                //                    mWebView.loadUrl(
                //                            "http://www.google.com/search?tbs="
                //                            + "mbl%3A1&hl=en&source=hp&biw=1170&bih=668&q="
                //                            + URLEncoder.encode(mSearchString, "UTF-8")
                //                            + "&btnG=Search");

                mWebView.loadUrl(Setup.CONFERENCE_STREAM + URLEncoder.encode(mSearchString, "UTF-8")
                        + "&method=gdd.stream");

            } catch (UnsupportedEncodingException e) {
                Log.e(TAG, "Could not construct the realtime search URL", e);
            }
        }
    });

    return root;
}

From source file:com.jmstudios.redmoon.fragment.ShadesFragment.java

private void showHelpSnackbar() {
    mHelpSnackbar = Snackbar.make(mView, getActivity().getString(R.string.help_snackbar_text),
            Snackbar.LENGTH_INDEFINITE);

    if (((ShadesActivity) getActivity()).getSettingsModel().getDarkThemeFlag()) {
        ViewGroup group = (ViewGroup) mHelpSnackbar.getView();
        group.setBackgroundColor(getActivity().getResources().getColor(R.color.snackbar_color_dark_theme));

        int snackbarTextId = android.support.design.R.id.snackbar_text;
        TextView textView = (TextView) group.findViewById(snackbarTextId);
        textView.setTextColor(getActivity().getResources().getColor(R.color.text_color_dark_theme));
    }/*from   www  .  java 2 s. com*/

    mHelpSnackbar.show();
}

From source file:com.mchp.android.PIC32_BTSK.TemperatureFragment.java

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

    super.onCreateView(inflater, container, savedInstanceState);

    // Inflate the layout for this fragment
    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_temperature, container, false);

    // Get each UI object from the layout
    mLastTemp = (TextView) rootView.findViewById(R.id.last_temp);
    mStart = (Button) rootView.findViewById(R.id.temp_start);
    mFrequency = (Button) rootView.findViewById(R.id.temp_freq);
    mSeekBarFreq = (SeekBar) rootView.findViewById(R.id.seek_freq);
    mProgressTextFreq = (TextView) rootView.findViewById(R.id.progress_freq);
    mDownFreq = (Button) rootView.findViewById(R.id.freq_down);
    mUpFreq = (Button) rootView.findViewById(R.id.freq_up);

    // Initialize the states of the UI objects
    mSeekBarFreq.setMax(freqValues.size() - 1);
    mSeekBarFreq.setProgress(freqValues.indexOf(mFreq));

    mLastTemp.setTextSize(100.0f);// www . ja  v  a 2s .co m
    mLastTemp.setText("--\u00b0");
    mStart.setText("Start/Stop");
    mFrequency.setText("Set Timer");
    mProgressTextFreq.setText(mFreq + " ms");
    mDownFreq.setText("-");
    mUpFreq.setText("+");

    // Set listeners for the UI objects
    mSeekBarFreq.setOnSeekBarChangeListener(this);

    // Define a click listener for the start/stop button. When clicked, it sends the start/stop command.
    mStart.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            mSendRequestCallback.onSendRequest(enableCmd);
        }
    });

    // Define a click listener for the timer button. When clicked, it sends the timer command with the current 
    // frequency.
    mFrequency.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            mSendRequestCallback.onSendRequest(timerCmd + "," + mFreq);
        }
    });

    // Define click listeners for the fine tune buttons. When clicked, they update the current frequency and 
    // update other UI elements with the new frequency.
    mDownFreq.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            mSeekBarValue = mSeekBarFreq.getProgress();
            mSeekBarValue--;
            mSeekBarFreq.setProgress(mSeekBarValue);
        }
    });
    mUpFreq.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            mSeekBarValue = mSeekBarFreq.getProgress();
            mSeekBarValue++;
            mSeekBarFreq.setProgress(mSeekBarValue);
        }
    });

    // Set up the graph
    // Create a new bar graph
    graphView = new BarGraphView(this.getActivity().getApplicationContext(), "");

    // Set the graph data to the values in the temperature log
    graphViewData = new GraphViewData[PIC32_BTSK.numTemperatures];
    setGraphViewData(mTempRequestCallback.onTempRequest());

    // Add the graph data to the graph.
    graphViewSeries = new GraphViewSeries(graphViewData);
    graphView.addSeries(graphViewSeries);

    // Setup the graph axis ranges, zoom and scroll
    graphView.setManualYAxisBounds(maxY, minY);
    graphView.setScalable(true);
    graphView.setScrollable(true);
    graphView.setViewPort(2, 40);

    // Setup the graph axes labels
    graphViewStyle = new GraphViewStyle();
    graphViewStyle.setHorizontalLabelsColor(0);
    graphViewStyle.setNumHorizontalLabels(2);
    graphViewStyle.setNumVerticalLabels(1 + (maxY - minY) / tickSize);
    graphView.setGraphViewStyle(graphViewStyle);

    // Add the graph to the layout
    LinearLayout g = (LinearLayout) rootView.findViewById(R.id.temp_graph);
    g.addView(graphView);

    graphView.scrollToEnd();

    // Return the layout for this fragment
    return rootView;
}

From source file:net.archenemy.archenemyapp.view.SlidingTabLayout.java

private void populateTabStrip() {
    final PagerAdapter adapter = viewPager.getAdapter();
    final View.OnClickListener tabClickListener = new TabClickListener();
    if (adapter.getCount() > 0) {
        int width = getResources().getDisplayMetrics().widthPixels;
        int tabWidth = width / adapter.getCount();
        for (int i = 0; i < adapter.getCount(); i++) {
            ViewGroup tabView = null;
            ImageView tabIcon = null;

            if (tabViewLayoutId != 0) {
                // If there is a custom tab view layout id set, try and inflate it
                tabView = (ViewGroup) LayoutInflater.from(getContext()).inflate(tabViewLayoutId, tabStrip,
                        false);//from   w w  w .ja va 2s.c om
                tabIcon = (ImageView) tabView.findViewById(tabViewImageViewId);
            }

            tabIcon.setImageResource(((BaseFragmentPagerAdapter) adapter).getIconResId(i));
            tabView.setOnClickListener(tabClickListener);
            tabStrip.addView(tabView, tabWidth, android.view.ViewGroup.LayoutParams.MATCH_PARENT);
        }
    }
}

From source file:com.ushahidi.android.app.ui.tablet.ListCheckinFragment.java

protected View headerView() {
    LayoutInflater inflater = getActivity().getLayoutInflater();
    ViewGroup viewGroup = (ViewGroup) inflater.inflate(R.layout.list_checkin_header, getListView(), false);
    TextView textView = (TextView) viewGroup.findViewById(R.id.filter_checkins);
    textView.addTextChangedListener(new TextWatcher() {

        public void afterTextChanged(Editable arg0) {

        }//from  w  ww.  jav a  2s  .  c o m

        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        public void onTextChanged(CharSequence s, int start, int before, int count) {

            if (!(TextUtils.isEmpty(s.toString()))) {
                filterTitle = s;
                mHandler.post(filterCheckinList);
            } else {
                mHandler.post(fetchCheckinList);
            }

        }

    });
    return viewGroup;
}

From source file:de.egore911.drilog.adapter.ShowDataAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    Object o = getItem(position);
    boolean isUser = o instanceof User;

    ViewGroup row;
    if (null == convertView) {
        // Create a new view for the user or comment
        if (isUser) {
            row = (RelativeLayout) layoutInflater.inflate(R.layout.line_name, null);
            UserViewHolder holder = new UserViewHolder();
            holder.nameField = (TextView) row.findViewById(R.id.name);
            holder.avatarField = (ImageView) row.findViewById(R.id.avatar);
            holder.user = (User) o;//from  w w  w.j a v  a2 s  . c  o  m
            row.setTag(holder);
        } else {
            row = (RelativeLayout) layoutInflater.inflate(R.layout.line_comment, null);
            CommentViewHolder holder = new CommentViewHolder();
            holder.commentField = (TextView) row.findViewById(R.id.comment);
            holder.dateField = (TextView) row.findViewById(R.id.date);
            holder.comment = (Comment) o;
            row.setTag(holder);
        }
    } else {
        // Recycle a previous view if possible
        row = (ViewGroup) convertView;
        if (isUser) {
            UserViewHolder holder = (UserViewHolder) row.getTag();
            holder.user = (User) o;
        } else {
            CommentViewHolder holder = (CommentViewHolder) row.getTag();
            holder.comment = (Comment) o;
        }
    }

    if (isUser) {
        User user = (User) o;

        setDefaultCellBackground(position, row, false);

        // Render a user
        UserViewHolder holder = (UserViewHolder) row.getTag();
        if (watchList != null && watchList.contains(user.nick)) {
            holder.nameField.setTypeface(null, Typeface.BOLD);
        } else {
            holder.nameField.setTypeface(null, Typeface.NORMAL);
        }
        holder.nameField.setText(user.name);
        Picasso.with(activity).load(user.image).placeholder(R.drawable.ic_launcher).into(holder.avatarField);
    } else {
        Comment comment = (Comment) o;

        setDefaultCellBackground(position, row, anchor == comment);

        // Render a comment
        CommentViewHolder holder = (CommentViewHolder) row.getTag();
        holder.commentField.setText(comment.content);
        holder.dateField.setText(comment.time);
    }

    return row;
}

From source file:com.ferasinfotech.gwreader.ScreenSlidePageFragment.java

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

    View.OnLongClickListener click_listener = new View.OnLongClickListener() {
        public boolean onLongClick(View v) {
            Intent i = new Intent(Intent.ACTION_VIEW);
            String s = "https://www.grasswire.com";

            if (mStoryID != 0) {
                s = s + "/story/" + mStoryID + "/x";
            }/* www  .  ja v a  2s  . c  om*/
            i.setData(Uri.parse(s));
            i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(i);

            return true;
        }
    };

    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_screen_slide_page, container, false);

    //      Picasso.with(getActivity()).setLoggingEnabled(true);
    //      Picasso.with(getActivity()).setIndicatorsEnabled(true);
    ImageView cover_image = (ImageView) rootView.findViewById(R.id.story_image);
    Picasso.with(getActivity()).load(mCoverPhoto).into(cover_image);

    cover_image.setOnLongClickListener(click_listener);

    ((TextView) rootView.findViewById(R.id.story_title)).setText(mTitle);
    ((TextView) rootView.findViewById(R.id.story_headline)).setText(mHeadline);
    ((TextView) rootView.findViewById(R.id.story_summary)).setText(mSummary);

    Log.d("***DEBUG***", "Building page:" + mPageNumber);

    if (mStoryID != 0) {
        LinksAdapter adapter = new LinksAdapter(getActivity(), mStoryString);
        LinearLayout ll = (LinearLayout) rootView.findViewById(R.id.story_layout);
        for (int i = 0; i < adapter.getCount(); i++) {
            View listItem = adapter.getView(i, null, ll);
            ll.addView(listItem);
        }
    }

    return rootView;
}