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) 

Source Link

Document

Inflate a new view hierarchy from the specified xml node.

Usage

From source file:com.glabs.homegenie.adapters.MediaRendererWidgetAdapter.java

@Override
public View getView(LayoutInflater inflater) {
    View v = _module.View;
    if (v == null) {
        v = inflater.inflate(R.layout.widget_item_upnprenderer, null);
        _module.View = v;/*from ww  w  .  ja  va  2s .c o m*/
        v.setTag(_module);
        //
        Button play = (Button) v.findViewById(R.id.playButton);
        play.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (!_playbackstatus.equals("PLAYING")) {
                    _mediaPlay();
                } else {
                    _mediaPause();
                }
            }
        });
        Button stop = (Button) v.findViewById(R.id.stopButton);
        stop.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                _mediaStop();
            }
        });
        Button prev = (Button) v.findViewById(R.id.prevButton);
        prev.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                _mediaPrev();
            }
        });
        Button next = (Button) v.findViewById(R.id.nextButton);
        next.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                _mediaNext();
            }
        });
        Button mute = (Button) v.findViewById(R.id.muteButton);
        mute.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (_currentmute.equals("1")) {
                    _mediaSetMute(0);
                } else {
                    _mediaSetMute(1);
                }
            }
        });
        SeekBar volbar = (SeekBar) v.findViewById(R.id.volumeSlider);
        volbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
                _mediaSetVolume(i);
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {
            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
            }
        });
    } else {
        v = _module.View;
    }
    return v;
}

From source file:com.example.healthplus.wifidirect.DeviceDetailFragment.java

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

    mContentView = inflater.inflate(R.layout.device_detail, null);
    mContentView.findViewById(R.id.btn_connect).setOnClickListener(new View.OnClickListener() {

        @Override/*w w w  . j a va  2s.  c  o m*/
        public void onClick(View v) {
            WifiP2pConfig config = new WifiP2pConfig();
            config.deviceAddress = device.deviceAddress;
            config.wps.setup = WpsInfo.PBC;
            if (progressDialog != null && progressDialog.isShowing()) {
                progressDialog.dismiss();
            }
            progressDialog = ProgressDialog.show(getActivity(), "Press back to cancel",
                    "Connecting to :" + device.deviceAddress, true, true
            //                        new DialogInterface.OnCancelListener() {
            //
            //                            @Override
            //                            public void onCancel(DialogInterface dialog) {
            //                                ((DeviceActionListener) getActivity()).cancelDisconnect();
            //                            }
            //                        }
            );
            ((DeviceActionListener) getActivity()).connect(config);

        }
    });

    mContentView.findViewById(R.id.btn_disconnect).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ((DeviceActionListener) getActivity()).disconnect();
        }
    });

    mContentView.findViewById(R.id.btn_start_client).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // Allow user to pick an image from Gallery or other
            // registered apps
            //Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
            //Log.d(WiFiDirectActivity.TAG, "Reached here Richa1");
            //intent.setType("image/*");
            //intent.setType("text/plain");
            //startActivityForResult(intent, CHOOSE_FILE_RESULT_CODE);
            //Log.d(WiFiDirectActivity.TAG, "Reached here Richa2");
            sendFile();

        }
    });

    return mContentView;
}

From source file:com.gmail.at.faint545.fragments.QueueFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.remote_queue, null);
    mPtrView = (PullToRefreshListView) view.findViewById(R.id.remote_queue_ptr);
    loadingStub = (ViewStub) view.findViewById(R.id.loading);

    mPtrView.setOnRefreshListener(new OnRefreshListener() {
        @Override//from www  . j a  v  a 2 s  .  c om
        public void onRefresh() {
            downloadQueue(mPtrView);
        }
    });
    return view;
}

From source file:de.vanita5.twittnuker.popup.AccountSelectorPopupWindow.java

public AccountSelectorPopupWindow(Context context, View anchor) {
    mContext = context;//from www.  j  a v a2s .c o m
    mAnchor = anchor;
    final int themeAttr;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        themeAttr = android.R.attr.actionOverflowMenuStyle;
    } else {
        themeAttr = android.R.attr.popupMenuStyle;
    }
    mAdapter = new AccountsGridAdapter(context);
    final Resources resources = context.getResources();
    final LayoutInflater inflater = LayoutInflater.from(context);
    final int themeColor = ThemeUtils.getUserAccentColor(context);
    if (!(context instanceof Factory)) {
        inflater.setFactory2(new ThemedViewFactory(themeColor));
    }
    final View contentView = inflater.inflate(R.layout.popup_account_selector, null);
    mGridView = (GridView) contentView.findViewById(R.id.grid_view);
    mGridView.setAdapter(mAdapter);
    mGridView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE);
    mGridView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (mAccountSelectionListener == null)
                return;

            mAccountSelectionListener.onSelectionChanged(getSelectedAccountIds());
        }
    });
    mPopup = new PopupWindow(context, null, themeAttr);
    mPopup.setFocusable(true);
    mPopup.setWidth(Utils.getActionBarHeight(context) * 2);
    mPopup.setWindowLayoutMode(0, ViewGroup.LayoutParams.WRAP_CONTENT);
    mPopup.setContentView(contentView);
}

From source file:com.redhorse.quickstart.AppConfig.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    dbStart = new dbStartConfigAdapter(this);
    dbStart.open();//from  w w w .ja v a  2  s  .co m

    loadApps(); // do this in onresume?

    setContentView(R.layout.applist);
    TabHost mTabHost = (TabHost) findViewById(R.id.tabhost);
    mTabHost.setup();
    LayoutInflater inflater_tab1 = LayoutInflater.from(this);
    inflater_tab1.inflate(R.layout.grid1, mTabHost.getTabContentView());
    inflater_tab1.inflate(R.layout.grid2, mTabHost.getTabContentView());
    mTabHost.addTab(mTabHost.newTabSpec("tab_test1")
            .setIndicator("", getResources().getDrawable(R.drawable.btn_add)).setContent(R.id.list1));
    mTabHost.addTab(mTabHost.newTabSpec("tab_test2")
            .setIndicator("", getResources().getDrawable(R.drawable.btn_remove)).setContent(R.id.list2));
    mList = (GridView) findViewById(R.id.list1);
    mList.setAdapter(new AppsAdapter());
    mList.setOnItemClickListener(Grid1ItemClickListener);
    mList2 = (GridView) findViewById(R.id.list2);
    mList2.setAdapter(new AppsAdapter2());
    mList2.setOnItemClickListener(Grid2ItemClickListener);
    Button button = (Button) findViewById(R.id.Button01);
    button.setOnClickListener(Button01Listener);
    button = (Button) findViewById(R.id.Button02);
    button.setOnClickListener(Button02Listener);
    button = (Button) findViewById(R.id.weibolist);
    button.setOnClickListener(weibolistListener);
}

From source file:com.jgraves.achievementunlocked.AchievementsList_Fragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    context = getActivity();// w  w w  .j  a v  a  2 s.  c o m
    rootView = inflater.inflate(R.layout.achievements_list, null);
    ll_main = (FrameLayout) rootView.findViewById(R.id.ll_main);
    ll_images_container = (LinearLayout) rootView.findViewById(R.id.ll_images);
    sv_images = (ObservableScrollView) rootView.findViewById(R.id.sv_images);
    sv_images.setCallbacks(this);
    mQuickReturnView = (LinearLayout) rootView.findViewById(R.id.sticky);
    tv_name = (TextView) rootView.findViewById(R.id.tv_name);
    tv_name.setText("Jordan Graves");
    tv_score = (TextView) rootView.findViewById(R.id.tv_score);
    tv_score.setText("Score: 150");
    profilePictureView = (ProfilePictureView) rootView.findViewById(R.id.selection_profile_pic);
    profilePictureView.setCropped(true);
    profilePictureView.setProfileId(ExploraApp.FACEBOOK_ID);

    sv_images.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            onScrollChanged(sv_images.getScrollY());
            mMaxScrollY = sv_images.computeVerticalScrollRange() - sv_images.getHeight();
            mQuickReturnHeight = mQuickReturnView.getHeight();
        }
    });

    return rootView;
}

From source file:com.geekytheory.miguelcatalandev.developerdays.Main_Fragment_Social.java

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

    inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.main_fragment_social, null);

    tweets = new ArrayList<Tweet>();
    adapter = new Social_Adapter_Tweets(getActivity(), tweets);
    return layout;
}

From source file:com.facebook.login.DeviceAuthDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    dialog = new Dialog(getActivity(), R.style.com_facebook_auth_dialog);
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View view = inflater.inflate(R.layout.com_facebook_device_auth_dialog_fragment, null);
    progressBar = (ProgressBar) view.findViewById(R.id.progress_bar);
    confirmationCode = (TextView) view.findViewById(R.id.confirmation_code);

    Button cancelButton = (Button) view.findViewById(R.id.cancel_button);
    cancelButton.setOnClickListener(new View.OnClickListener() {
        @Override// w  ww.  ja v  a 2s.co  m
        public void onClick(View v) {
            onCancel();
        }
    });

    TextView instructions = (TextView) view.findViewById(R.id.com_facebook_device_auth_instructions);
    instructions.setText(Html.fromHtml(getString(R.string.com_facebook_device_auth_instructions)));

    dialog.setContentView(view);
    return dialog;
}

From source file:fr.cph.chicago.adapter.BusAdapter.java

@Override
public final View getView(final int position, View convertView, ViewGroup parent) {

    final BusRoute route = (BusRoute) getItem(position);

    TextView routeNameView = null;/*from w  ww  .j  av  a 2  s .  c  om*/
    TextView routeNumberView = null;
    LinearLayout detailsLayout = null;

    if (convertView == null) {
        LayoutInflater vi = (LayoutInflater) ChicagoTracker.getAppContext()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = vi.inflate(R.layout.list_bus, null);

        final ViewHolder holder = new ViewHolder();
        routeNameView = (TextView) convertView.findViewById(R.id.station_name);
        holder.routeNameView = routeNameView;

        routeNumberView = (TextView) convertView.findViewById(R.id.bike_availability);
        holder.routeNumberView = routeNumberView;

        detailsLayout = (LinearLayout) convertView.findViewById(R.id.route_details);
        holder.detailsLayout = detailsLayout;

        convertView.setTag(holder);

        convertView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                holder.detailsLayout.setVisibility(LinearLayout.VISIBLE);
                mActivity.startRefreshAnimation();
                new DirectionAsyncTask().execute(route, holder.detailsLayout);
            }
        });
    } else {
        final ViewHolder holder = (ViewHolder) convertView.getTag();
        routeNameView = holder.routeNameView;
        routeNumberView = holder.routeNumberView;
        detailsLayout = holder.detailsLayout;

        convertView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                holder.detailsLayout.setVisibility(LinearLayout.VISIBLE);
                mActivity.startRefreshAnimation();
                new DirectionAsyncTask().execute(route, holder.detailsLayout);
            }
        });
    }

    routeNameView.setText(route.getName());
    routeNumberView.setText(route.getId());

    return convertView;
}