Example usage for android.view LayoutInflater inflate

List of usage examples for android.view LayoutInflater inflate

Introduction

In this page you can find the example usage for android.view LayoutInflater inflate.

Prototype

public View inflate(XmlPullParser parser, @Nullable ViewGroup root, boolean attachToRoot) 

Source Link

Document

Inflate a new view hierarchy from the specified XML node.

Usage

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  www  .j a v a 2s  .  c o  m
}

From source file:com.sawyer.advadapters.app.adapters.jsonadapter.JSONAdapterFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ListView lv = (ListView) inflater.inflate(R.layout.listview, container, false);
    lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
    lv.setMultiChoiceModeListener(new OnCabMultiChoiceModeListener());
    return lv;// ww  w  .  j  a  v a2  s .  c om
}

From source file:com.github.rutvijkumar.twittfuse.adapters.UserArrayAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    // Get the data item for this position
    final User user = getItem(position);
    // Check if an existing view is being reused, otherwise inflate the view

    ViewHolder viewHolder; // view lookup cache stored in tag
    if (convertView == null) {
        viewHolder = new ViewHolder();
        LayoutInflater inflater = LayoutInflater.from(getContext());
        convertView = inflater.inflate(R.layout.user_item, parent, false);

        viewHolder.name = (TextView) convertView.findViewById(R.id.tv_username);
        viewHolder.screenName = (TextView) convertView.findViewById(R.id.tv_screenname);
        viewHolder.userBio = (TextView) convertView.findViewById(R.id.tv_userBio);
        viewHolder.userProfilePic = (ImageView) convertView.findViewById(R.id.img_profilepic);

        viewHolder.followAction = (ImageButton) convertView.findViewById(R.id.tvFollow);

        convertView.setTag(viewHolder);//from   ww  w . j  av a2 s.  c  o m
    } else {
        viewHolder = (ViewHolder) convertView.getTag();
    }
    // Populate the data into the template view using the data object

    viewHolder.userProfilePic.setImageResource(android.R.color.transparent);
    ImageLoader imageLoader = ImageLoader.getInstance();
    imageLoader.displayImage(user.getProfileImageUrl(), viewHolder.userProfilePic);

    viewHolder.name.setText(user.getName());
    viewHolder.screenName.setText("@" + user.getScreenName());
    viewHolder.userProfilePic.setTag(user);
    viewHolder.userBio.setText(user.getDescription());

    if (!user.isFollowing()) {
        viewHolder.followAction.setVisibility(View.VISIBLE);
        final ImageButton imgBtn = viewHolder.followAction;
        viewHolder.followAction.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                client.followUser(user.getScreenName(), new JsonHttpResponseHandler() {
                    @Override
                    public void onSuccess(JSONObject arg0) {
                        imgBtn.setVisibility(View.INVISIBLE);
                    }
                });

            }
        });
    } else {
        viewHolder.followAction.setVisibility(View.INVISIBLE);
    }

    //pullToRefreshListView setOnItem click listerner is not working because of auto link
    convertView.setOnClickListener(new UserOnClickListener(user));
    viewHolder.userProfilePic.setOnClickListener(new UserOnClickListener(user));

    return convertView;
}

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

@Nullable
@Override//from ww  w . j ava2  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:com.imalu.alyou.activity.ConcernlistFragment.java

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    return inflater.inflate(R.layout.contact_concern_list, container, false);
}

From source file:com.networksaremadeofstring.anonionooid.RelayGraphDetailsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_details_swipe_graphs, container, false);
    graphContainer = (LinearLayout) rootView.findViewById(R.id.graphContainer);
    return rootView;
}

From source file:com.imalu.alyou.activity.FanslistFragment.java

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    return inflater.inflate(R.layout.contact_fans_list, container, false);
}

From source file:fr.cph.chicago.fragment.BusFragment.java

@Override
public final View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_bus, container, false);
    if (!mActivity.isFinishing()) {
        mTextFilter = (EditText) rootView.findViewById(R.id.bus_filter);
        mListView = (ListView) rootView.findViewById(R.id.bus_list);
        if (Util.isNetworkAvailable()) {
            addView();/*from   w  ww  . j  av a  2s  .  co  m*/
        } else {
            Toast.makeText(ChicagoTracker.getAppContext(), "No network connection detected!",
                    Toast.LENGTH_SHORT).show();
        }
    }
    return rootView;
}

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

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_photo_add_to_gallery_list, container, false);
    this.listView = (AbsListView) view.findViewById(android.R.id.list);
    this.listView.setOnItemClickListener(this);
    this.listView.setAdapter(new PhotoAddToGalleryListAdapter(getActivity(), this.galleries));
    Button button = (Button) view.findViewById(R.id.button_save);
    button.setOnClickListener(this);
    return view;/*  w  w w.  j  a va2 s .  c  o m*/
}

From source file:models.newArrivalFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_newarrival, container, false);
    getActivity().setTitle("New Arrivals!");

    //animation when enter home page
    rootView.startAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.image_click));

    //download the URL's asynchronously (put the info in the teaInfo object)
    try {/*from ww w . ja  v a  2  s .  co  m*/
        teaInfo = new GetTeaInfoTask().execute(new ApiConnector()).get();
    } catch (InterruptedException e) {
        e.printStackTrace();
    } catch (ExecutionException e) {
        e.printStackTrace();
    }
    //make the gridview and set its adapter
    GridView gridView = (GridView) rootView.findViewById(R.id.grid_view_new_arrival);
    GridViewCustomAdapter gvAdapter = new GridViewCustomAdapter(getActivity(), teaInfo.imageURLs,
            teaInfo.teaNames);
    gridView.setAdapter(gvAdapter);

    //onclick listener for gridview
    gridView.setOnItemClickListener(new OnItemClickListener() {

        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {

            Bundle teaViewArgs = new Bundle();
            teaViewArgs.putString("teaName", teaInfo.teaNames.get(position));
            teaViewArgs.putString("teaImgUrl", teaInfo.imageURLs.get(position));
            teaViewArgs.putString("teaDesc", teaInfo.teaDescriptions.get(position));
            Fragment newFragment = new TeaViewFragment();
            newFragment.setArguments(teaViewArgs);

            if (newFragment != null) {
                flipCard(newFragment);
            }
        }

        private void flipCard(Fragment newFragment) {
            mShowingBack = true;
            FragmentManager fragmentManager = getFragmentManager();
            fragmentManager.beginTransaction()
                    .setCustomAnimations(R.anim.card_flip_right_in, R.anim.card_flip_right_out,
                            R.anim.card_flip_left_in, R.anim.card_flip_left_out)
                    .replace(R.id.frame_container, newFragment).addToBackStack(null).commit(); // create new fragment and allow user to go back to previous fragment          
        }

    });

    return rootView;
}