List of usage examples for android.view LayoutInflater inflate
public View inflate(XmlPullParser parser, @Nullable ViewGroup root, boolean attachToRoot)
From source file:cn.edu.wyu.documentviewer.RecentsCreateFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final Context context = inflater.getContext(); final View view = inflater.inflate(R.layout.fragment_directory, container, false); mEmptyView = view.findViewById(android.R.id.empty); mListView = (ListView) view.findViewById(R.id.list); mListView.setOnItemClickListener(mItemListener); mAdapter = new DocumentStackAdapter(); mListView.setAdapter(mAdapter);//www .j av a2 s. co m final RootsCache roots = DocumentsApplication.getRootsCache(context); final State state = ((DocumentsActivity) getActivity()).getDisplayState(); mCallbacks = new LoaderCallbacks<List<DocumentStack>>() { @Override public Loader<List<DocumentStack>> onCreateLoader(int id, Bundle args) { return new RecentsCreateLoader(context, roots, state); } @Override public void onLoadFinished(Loader<List<DocumentStack>> loader, List<DocumentStack> data) { mAdapter.swapStacks(data); // When launched into empty recents, show drawer if (mAdapter.isEmpty() && !state.stackTouched) { ((DocumentsActivity) context).setRootsDrawerOpen(true); } } @Override public void onLoaderReset(Loader<List<DocumentStack>> loader) { mAdapter.swapStacks(null); } }; return view; }
From source file:com.coodesoft.notee.DataAdapter.java
public View getView(int position, View convertView, ViewGroup parent) { boolean isLastRow = position >= m_nItemsLoaded; int rowResID = isLastRow ? loadingRowResID : itemRowResID; LayoutInflater inflater = LayoutInflater.from(context); View v = inflater.inflate(rowResID, parent, false); if (isLastRow) { if (position < m_nNoteAmount) { // Should there be more items loaded? int nextItemToLoad = position + PRELOAD_ITEMS; if (nextItemToLoad > m_nNoteAmount) nextItemToLoad = m_nNoteAmount; Log.d(LOG_TAG, "nextItemToLoad: " + nextItemToLoad); if (nextItemToLoad > m_nItemsLoaded) { Log.d(LOG_TAG, "itemsToLoad: " + nextItemToLoad); // Launch the loading thread if it is not currently running synchronized (loading) { if (!loading.booleanValue()) { Log.d(LOG_TAG, "Staring loading task"); loading = Boolean.TRUE; m_threadLoading = new LoadingThread(); m_threadLoading.start(); Log.d(LOG_TAG, "Loading task started"); }/*w w w . ja v a 2 s .c o m*/ } } } else uiHandler.post(updateTask); } else { synchronized (m_lstNoteItems) { NoteItem item = m_lstNoteItems.get(position); // title TextView itemControl = (TextView) v.findViewById(R.id.note_item_title); itemControl.setText(item.m_strTitle); // set at TextView itemDate = (TextView) v.findViewById(R.id.note_item_subtitle); itemDate.setText(item.getSetAt()); // icon ImageView imageView = (ImageView) v.findViewById(R.id.image_view_icon); if (item.isNote()) imageView.setImageResource(R.drawable.ic_note); else imageView.setImageResource(R.drawable.ic_schedule); } } return v; }
From source file:io.openkit.leaderboards.OKLeaderboardsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Note: have to lookup id manually for Unity int viewID = getResources().getIdentifier("io_openkit_fragment_leaderboards", "layout", getActivity().getPackageName()); View view = inflater.inflate(viewID, container, false); int spinnerBarID = getResources().getIdentifier("progressSpinner", "id", getActivity().getPackageName()); int listHeaderViewID = getResources().getIdentifier("list_simple_header", "layout", getActivity().getPackageName()); int listHeaderTextViewID = getResources().getIdentifier("headerTextView", "id", getActivity().getPackageName()); listView = (ListView) view.findViewById(android.R.id.list); spinnerBar = (ProgressBar) view.findViewById(spinnerBarID); View listHeaderView = inflater.inflate(listHeaderViewID, null); listHeaderTextView = (TextView) listHeaderView.findViewById(listHeaderTextViewID); listView.addHeaderView(listHeaderView); listHeaderTextView.setText(numPlayers + " Players"); //Only do this the first time when fragment is created if (!startedLeaderboardsRequest) { getLeaderboards();/* w ww . ja v a2s . c o m*/ /* if(OKUser.getCurrentUser() == null) { OKLog.v("Launching login view becuase no user is logged in"); Intent launchLogin = new Intent(this.getActivity(), OKLoginActivity.class); startActivity(launchLogin); }*/ } OKLog.v("On create view leaderboards"); return view; }
From source file:com.cpyf.twelve.spies.qr.code.book.SearchBookContentsActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); // Make sure that expired cookies are removed on launch. CookieSyncManager.createInstance(this); CookieManager.getInstance().removeExpiredCookie(); Intent intent = getIntent();/* w w w.j a v a 2s. co m*/ if (intent == null || !intent.getAction().equals(Intents.SearchBookContents.ACTION)) { finish(); return; } isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN); if (LocaleManager.isBookSearchUrl(isbn)) { setTitle(getString(R.string.sbc_name)); } else { setTitle(getString(R.string.sbc_name) + ": ISBN " + isbn); } setContentView(R.layout.search_book_contents); queryTextView = (EditText) findViewById(R.id.query_text_view); String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY); if (initialQuery != null && initialQuery.length() > 0) { // Populate the search box but don't trigger the search queryTextView.setText(initialQuery); } queryTextView.setOnKeyListener(keyListener); queryButton = (Button) findViewById(R.id.query_button); queryButton.setOnClickListener(buttonListener); resultListView = (ListView) findViewById(R.id.result_list_view); LayoutInflater factory = LayoutInflater.from(this); headerView = (TextView) factory.inflate(R.layout.search_book_contents_header, resultListView, false); resultListView.addHeaderView(headerView); }
From source file:org.sirimangalo.meditationplus.AdapterMed.java
@Override public View getView(final int position, View convertView, ViewGroup parent) { View rowView;/*from www .j av a 2 s. com*/ if (convertView == null) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); rowView = inflater.inflate(R.layout.list_item_med, parent, false); } else { rowView = convertView; } JSONObject p = values.get(position); TextView walk = (TextView) rowView.findViewById(R.id.one_walking); TextView sit = (TextView) rowView.findViewById(R.id.one_sitting); ImageView status = (ImageView) rowView.findViewById(R.id.one_status); TextView name = (TextView) rowView.findViewById(R.id.one_med); ImageView flag = (ImageView) rowView.findViewById(R.id.one_flag); View anuView = rowView.findViewById(R.id.anumodana_shell); TextView anuText = (TextView) rowView.findViewById(R.id.anumodana); try { String wo = p.getString("walking"); String so = p.getString("sitting"); int wi = Integer.parseInt(wo); int si = Integer.parseInt(so); int ti = Integer.parseInt(p.getString("start")); int ei = Integer.parseInt(p.getString("end")); long nowL = System.currentTimeMillis() / 1000; int now = (int) nowL; boolean finished = false; String ws = "0"; String ss = "0"; if (ei > now) { float secs = now - ti; if (secs > wi * 60 || wi == 0) { //walking done float ssecs = (int) (secs - (wi * 60)); if (ssecs < si * 60) // still sitting ss = Integer.toString((int) Math.floor(si - ssecs / 60)); status.setImageResource(R.drawable.sitting_icon); } else { // still walking ws = Integer.toString((int) Math.floor(wi - secs / 60)); ss = so; status.setImageResource(R.drawable.walking_icon); } ws += "/" + wo; ss += "/" + so; } else { ws = wo; ss = so; double age = 1 - (now - ei) / MAX_AGE; String ageColor = Integer.toHexString((int) (255 * age)); if (ageColor.length() == 1) ageColor = "0" + ageColor; int alpha = Color.parseColor("#" + ageColor + "000000"); walk.setTextColor(alpha); sit.setTextColor(alpha); name.setTextColor(alpha); status.setAlpha((float) age); flag.setAlpha((float) age); } walk.setText(ws); sit.setText(ss); if (p.has("country")) { int id = context.getResources().getIdentifier("flag_" + p.getString("country").toLowerCase(), "drawable", context.getPackageName()); flag.setImageResource(id); flag.setVisibility(View.VISIBLE); } final String username = p.getString("username"); final String edit = p.getString("can_edit"); name.setText(username); name.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { context.showProfile(username); } }); String type = p.getString("type"); if ("love".equals(type)) status.setImageResource(R.drawable.love_icon); String anu = p.getString("anumodana"); if (!anu.equals("0")) anuText.setText(anu); if (p.getString("anu_me").equals("1")) { anuText.setTextColor(0xFF00BB00); anuText.setTypeface(null, Typeface.BOLD); } final String sid = p.getString("sid"); anuView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Log.d(TAG, "anu clicked"); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String loggedUsername = prefs.getString("username", ""); String loginToken = prefs.getString("login_token", ""); ArrayList<NameValuePair> nvp = new ArrayList<NameValuePair>(); nvp.add(new BasicNameValuePair("form_id", "anumed_" + sid)); nvp.add(new BasicNameValuePair("login_token", loginToken)); nvp.add(new BasicNameValuePair("submit", "Refresh")); nvp.add(new BasicNameValuePair("username", loggedUsername)); nvp.add(new BasicNameValuePair("source", "android")); PostTaskRunner postTask = new PostTaskRunner(postHandler, context); postTask.doPostTask(nvp); } }); } catch (Exception e) { e.printStackTrace(); } return rowView; }
From source file:com.example.harish.b2bapplication.activity.ProfileFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_profile, container, false); _lastname = (EditText) rootView.findViewById(R.id.lastname); _firstname = (EditText) rootView.findViewById(R.id.firstname); _nameoffirm = (EditText) rootView.findViewById(R.id.nameoffirm); _estyear = (EditText) rootView.findViewById(R.id.estyear); _website = (EditText) rootView.findViewById(R.id.website); _pan = (EditText) rootView.findViewById(R.id.pan); _tanvat = (EditText) rootView.findViewById(R.id.tanvat); _bankacc = (EditText) rootView.findViewById(R.id.bankacc); _billingaddress = (EditText) rootView.findViewById(R.id.billingaddress); _deliveryaddress = (EditText) rootView.findViewById(R.id.deliveryaddress); //-------------------------------Getting User ID and Token----------------------------- s = new StoreAck().readFile(getContext().getApplicationContext()); ack = s[0];//from w w w .ja va 2s . c o m userid = s[1]; //------------------------------------Getting Profile and Intialising new GetProfile().getProfile(ack, userid, getContext(), this); profileUpdateBtn = (Button) rootView.findViewById(R.id.btn_updateprofile); profileUpdateBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { lastname = _lastname.getText().toString(); firstname = _firstname.getText().toString(); nameoffirm = _nameoffirm.getText().toString(); estyear = _estyear.getText().toString(); website = _website.getText().toString(); pan = _pan.getText().toString(); tanvat = _tanvat.getText().toString(); bankacc = _bankacc.getText().toString(); billingaddress = _billingaddress.getText().toString(); deliveryaddress = _deliveryaddress.getText().toString(); ConnectionDetector connectionDetector = new ConnectionDetector(getContext()); if (connectionDetector.isConnectingToInternet()) { updateProfile(); } else { connectionDetector.showConnectivityStatus(); } } }); // Inflate the layout for this fragment return rootView; }
From source file:com.ronnyml.sweetplayer.fragments.ExploreFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_explore, container, false); mActivity = getActivity();//w w w . ja va 2 s .c o m mLoadingBar = (ProgressBar) rootView.findViewById(R.id.loading_bar); mSearchEditText = (EditText) rootView.findViewById(R.id.search_edit_text); mSearchImageButton = (ImageButton) rootView.findViewById(R.id.search_imagebutton); mTopArtistsLayout = (LinearLayout) rootView.findViewById(R.id.top_artists_layout); mTopArtistsRecyclerView = (RecyclerView) rootView.findViewById(R.id.top_artists_recyclerview); mTopGenresLayout = (LinearLayout) rootView.findViewById(R.id.top_genres_layout); mTopGenresRecyclerView = (RecyclerView) rootView.findViewById(R.id.top_genres_recyclerview); mTopPlaylistsLayout = (LinearLayout) rootView.findViewById(R.id.top_playlists_layout); mTopPlaylistsRecyclerView = (RecyclerView) rootView.findViewById(R.id.top_playlists_recyclerview); mTopSongsLayout = (LinearLayout) rootView.findViewById(R.id.top_songs_layout); mTopSongsListview = (ObservableListView) rootView.findViewById(R.id.top_songs_listview); LinearLayoutManager mArtistsLinearLayoutManager = new LinearLayoutManager( mActivity.getApplicationContext()); mArtistsLinearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); mTopArtistsRecyclerView.setLayoutManager(mArtistsLinearLayoutManager); mTopArtistsRecyclerView.setItemAnimator(new DefaultItemAnimator()); LinearLayoutManager mGenresLinearLayoutManager = new LinearLayoutManager(mActivity.getApplicationContext()); mGenresLinearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); mTopGenresRecyclerView.setLayoutManager(mGenresLinearLayoutManager); mTopGenresRecyclerView.setItemAnimator(new DefaultItemAnimator()); LinearLayoutManager mPlaylistsLinearLayoutManager = new LinearLayoutManager( mActivity.getApplicationContext()); mPlaylistsLinearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); mTopPlaylistsRecyclerView.setLayoutManager(mPlaylistsLinearLayoutManager); mTopPlaylistsRecyclerView.setItemAnimator(new DefaultItemAnimator()); setupSearchButton(); if (Utils.isConnectedToInternet(mActivity)) { getRequest(Constants.PLAYLIST_URL, 0); getRequest(Constants.GENRES_URL, 1); getRequest(Constants.ARTISTS_URL, 2); getRequest(Constants.TOP_URL, 3); } else { Utils.showAlertDialog(mActivity, mActivity.getString(R.string.internet_no_connection_title), mActivity.getString(R.string.internet_no_connection_message)); } return rootView; }
From source file:fr.bde_eseo.eseomega.community.CommunityFragment.java
@Override public View onCreateView(LayoutInflater rootInfl, ViewGroup container, Bundle savedInstanceState) { // UI/*from w ww.ja v a 2 s .co m*/ View rootView = rootInfl.inflate(R.layout.fragment_club_list, container, false); swipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.clubs_refresh); swipeRefreshLayout.setColorSchemeColors(R.color.md_blue_800); progCircle = (ProgressBar) rootView.findViewById(R.id.progressClubs); progCircle.getIndeterminateDrawable().setColorFilter(getResources().getColor(R.color.md_grey_500), PorterDuff.Mode.SRC_IN); tv1 = (TextView) rootView.findViewById(R.id.tvListNothing); tv2 = (TextView) rootView.findViewById(R.id.tvListNothing2); img = (ImageView) rootView.findViewById(R.id.imgNoClub); progCircle.setVisibility(View.GONE); tv1.setVisibility(View.GONE); tv2.setVisibility(View.GONE); img.setVisibility(View.GONE); disabler = new RecyclerViewDisabler(); // I/O cache data cachePath = getActivity().getCacheDir() + "/"; cacheFileEseo = new File(cachePath + "community.json"); // Model / objects mAdapter = new MyCommunityAdapter(); recList = (RecyclerView) rootView.findViewById(R.id.recyList); recList.setAdapter(mAdapter); recList.setHasFixedSize(true); LinearLayoutManager llm = new LinearLayoutManager(getActivity()); llm.setOrientation(LinearLayoutManager.VERTICAL); recList.setLayoutManager(llm); mAdapter.notifyDataSetChanged(); // Start download of data AsyncJSON asyncJSON = new AsyncJSON(true); // circle needed for first call asyncJSON.execute(Constants.URL_JSON_CLUBS); // Swipe-to-refresh implementations timestamp = 0; swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { //Toast.makeText(getActivity(), "Refreshing ...", Toast.LENGTH_SHORT).show(); long t = System.currentTimeMillis() / 1000; if (t - timestamp > LATENCY_REFRESH) { // timestamp in seconds) timestamp = t; AsyncJSON asyncJSON = new AsyncJSON(false); // no circle here (already in SwipeLayout) asyncJSON.execute(Constants.URL_JSON_CLUBS); } else { swipeRefreshLayout.setRefreshing(false); } } }); recList.addOnItemTouchListener( new RecyclerItemClickListener(getActivity(), new RecyclerItemClickListener.OnItemClickListener() { @Override public void onItemClick(View view, int position) { // Start activity Intent myIntent = new Intent(getActivity(), ClubViewActivity.class); myIntent.putExtra(Constants.KEY_CLUB_VIEW, position); startActivity(myIntent); } })); return rootView; }
From source file:com.example.cuisoap.agrimac.homePage.homeFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment view = inflater.inflate(R.layout.fragment_home, container, false); LinearLayout machine_new = (LinearLayout) view.findViewById(R.id.machine_new_layout); list = (ListView) view.findViewById(R.id.machine_listview); data = new ArrayList<>(); adapter = new machineAdapter(mContext); list.setAdapter(adapter);/*w w w .ja v a 2s. co m*/ list.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent i = new Intent(mContext, machineDetailActivity.class); i.putExtra("data", (HashMap<String, String>) adapter.getItem(position)); startActivityForResult(i, 1); } }); machine_new.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startActivityForResult(new Intent(mContext, containerActivity.class), 0); } }); // test(); new Thread(send).start(); return view; }
From source file:com.he5ed.lib.cloudprovider.auth.OAuth2Fragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View rootView = inflater.inflate(R.layout.cp_fragment_oauth, container, false); mRootView = (FrameLayout) rootView;/*from w w w .j a v a 2 s . c o m*/ // insert web view if (mWebView == null) { mWebView = new OAuthWebView(getActivity()); mWebView.setOnAuthEndListener(this); mWebView.authenticate(mCloudApi); mWebView.setFocusable(true); mWebView.setFocusableInTouchMode(true); mWebView.requestFocus(View.FOCUS_DOWN); } mRootView.addView(mWebView, FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT); return rootView; }