List of usage examples for android.view LayoutInflater inflate
public View inflate(XmlPullParser parser, @Nullable ViewGroup root, boolean attachToRoot)
From source file:com.cw.litenote.operation.import_export.Import_filesList.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { rootView = inflater.inflate(R.layout.import_sd_files_list, container, false); View view = rootView.findViewById(R.id.view_back_btn_bg); view.setBackgroundColor(ColorSet.getBarColor(getActivity())); // back button Button backButton = (Button) rootView.findViewById(R.id.view_back); backButton.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_menu_back, 0, 0, 0); // update button Button renewButton = (Button) rootView.findViewById(R.id.view_renew); renewButton.setCompoundDrawablesWithIntrinsicBounds(android.R.drawable.ic_popup_sync, 0, 0, 0); // do cancel/* w w w . ja v a2s .co m*/ backButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { getActivity().getSupportFragmentManager().popBackStack(); } }); // do update renewButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { // source dir: Download String srcDirName = "Download";//todo Could be empty String srcDirPath = Environment.getExternalStorageDirectory().toString() + "/" + srcDirName; System.out.println("srcDirPath = " + srcDirPath); /** * Note about getExternalStorageDirectory: * don't be confused by the word "external" here. * This directory can better be thought as media/shared storage. * It is a filesystem that can hold a relatively large amount of data and * that is shared across all applications (does not enforce permissions). * Traditionally this is an SD card, but it may also be implemented as built-in storage in a device * that is distinct from the protected internal storage and can be mounted as a filesystem on a computer. */ // target dir String targetDirPath = Environment.getExternalStorageDirectory().toString() + "/" + Util.getStorageDirName(getActivity()); // copy source files to target directory File srcDir = new File(srcDirPath); if (srcDir.exists()) { for (File srcFile : srcDir.listFiles()) { File targetFile = new File(targetDirPath + "/" + srcFile.getName()); System.out.println("targetFile.getName() = " + targetFile.getName()); try { if (srcFile.getName().contains("XML") || srcFile.getName().contains("xml")) FileUtils.copyFile(srcFile, targetFile); } catch (IOException e) { e.printStackTrace(); } } } // refresh list view File dir = new File(targetDirPath); getFiles(dir.listFiles()); } }); ((MainAct) getActivity()).setOnBackPressedListener(new BaseBackPressedListener(MainAct.mAct)); return rootView; }
From source file:com.clearner.youtube.YouTubeFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Picasso.with(getActivity()).setDebugging(true); View rootView = inflater.inflate(R.layout.youtube_fragment, container, false); mListView = (ListView) rootView.findViewById(R.id.youtube_listview); // restore the playlist after an orientation change /* if (savedInstanceState != null) { mPlaylist = new Gson().fromJson(savedInstanceState.getString(PLAYLIST_KEY), Playlist.class); }//from www .java 2s . co m */ // ensure the adapter and listview are initialized if (mPlaylist != null) { initListAdapter(mPlaylist); } // start loading the first page of our playlist new GetYouTubePlaylistAsyncTask() { @Override public EtagCache getEtagCache() { return mEtagCache; } @Override public void onPostExecute(JSONObject result) { handlePlaylistResult(result); } }.execute(PLAYLIST_KEY, null); return rootView; }
From source file:com.QuarkLabs.BTCeClient.fragments.OrdersBookFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { setHasOptionsMenu(true);/* w ww. j av a 2 s. c o m*/ @SuppressLint("InflateParams") View v = inflater.inflate(R.layout.fragment_ordersbook, container, false); mAsksList = (ListView) v.findViewById(R.id.asks); mBidsList = (ListView) v.findViewById(R.id.bids); mChartArea = (FrameLayout) v.findViewById(R.id.OrdersBookChart); mLoadingViewAsks = new ProgressBar(getActivity()); mLoadingViewBids = new ProgressBar(getActivity()); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT); lp.gravity = Gravity.CENTER; mLoadingViewAsks.setLayoutParams(lp); mLoadingViewBids.setLayoutParams(lp); ((LinearLayout) mAsksList.getParent()).addView(mLoadingViewAsks); mAsksList.setEmptyView(mLoadingViewAsks); ((LinearLayout) mBidsList.getParent()).addView(mLoadingViewBids); mBidsList.setEmptyView(mLoadingViewBids); ActionBarActivity hostActivity = (ActionBarActivity) getActivity(); hostActivity.getSupportActionBar().setCustomView(mPairsSpinner, new ActionBar.LayoutParams(Gravity.END)); hostActivity.getSupportActionBar().setDisplayShowCustomEnabled(true); return v; }
From source file:com.zd.vpn.fragments.AboutFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.about, container, false); // TextView ver = (TextView) v.findViewById(R.id.version); String version;// w ww .ja va2 s.c om String name = "Openvpn"; try { PackageInfo packageinfo = getActivity().getPackageManager() .getPackageInfo(getActivity().getPackageName(), 0); version = packageinfo.versionName; name = getString(R.string.app); } catch (NameNotFoundException e) { version = "error fetching version"; } // ver.setText(getString(R.string.version_info, name, version)); // // TextView paypal = (TextView) v.findViewById(R.id.donatestring); // // String donatetext = getActivity().getString(R.string.donatewithpaypal); // Spanned htmltext = Html.fromHtml(donatetext); // paypal.setText(htmltext); // paypal.setMovementMethod(LinkMovementMethod.getInstance()); // gmsTextView = (TextView) v.findViewById(R.id.donategms); /* recreating view without onCreate/onDestroy cycle */ // Disable GMS for now if (mService != null) initGooglePlayDonation(); // TextView translation = (TextView) v.findViewById(R.id.translation); // // // Don't print a text for myself // if (getString(R.string.translationby).contains("Arne Schwabe")) // translation.setText(""); // else // translation.setText(R.string.translationby); // // WebView wv = (WebView)v.findViewById(R.id.webView); // wv.loadUrl("file:///android_asset/full_licenses.html"); return v; }
From source file:com.manning.androidhacks.hack040.ImageGridFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View v = inflater.inflate(R.layout.image_grid_fragment, container, false); final GridView mGridView = (GridView) v.findViewById(R.id.gridView); mGridView.setAdapter(mAdapter);/*from w w w.j a va 2s . c o m*/ mGridView.setOnItemClickListener(this); // This listener is used to get the final width of the GridView and then // calculate the // number of columns and the width of each column. The width of each column // is variable // as the GridView has stretchMode=columnWidth. The column width is used to // set the height // of each view so we get nice square thumbnails. mGridView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { if (mAdapter.getNumColumns() == 0) { final int numColumns = (int) Math .floor(mGridView.getWidth() / (mImageThumbSize + mImageThumbSpacing)); if (numColumns > 0) { final int columnWidth = (mGridView.getWidth() / numColumns) - mImageThumbSpacing; mAdapter.setNumColumns(numColumns); mAdapter.setItemHeight(columnWidth); if (BuildConfig.DEBUG) { Log.d(TAG, "onCreateView - numColumns set to " + numColumns); } } } } }); return v; }
From source file:es.uniovi.imovil.fcrtrainer.NetworkLayerExerciseFragment.java
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { rootView = inflater.inflate(R.layout.fragment_layer, container, false); //TextView para mostrar la pregunta pregunta = (TextView) rootView.findViewById(R.id.textlayer); //TextView para los puntos en el modo jugar layerPoints = (TextView) rootView.findViewById(R.id.points_layer); //Radiogrup// w w w . java 2 s . c om opciones = (RadioGroup) rootView.findViewById(R.id.layer_group); rb_layer = (RadioButton) rootView.findViewById(R.id.link_layer); rb_network = (RadioButton) rootView.findViewById(R.id.internet_layer); rb_transport = (RadioButton) rootView.findViewById(R.id.transport_layer); rb_application = (RadioButton) rootView.findViewById(R.id.application_layer); opciones.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { public void onCheckedChanged(RadioGroup rGroup, int checkedId) { // TODO Auto-generated method stub switch (checkedId) { case R.id.link_layer: rb_pressed = "Capa de enlace"; break; case R.id.internet_layer: rb_pressed = "Capa de internet"; break; case R.id.transport_layer: rb_pressed = "Capa de transporte"; break; case R.id.application_layer: rb_pressed = "Capa de aplicacin"; break; } RadioButton checkedRadioButton = (RadioButton) opciones .findViewById(opciones.getCheckedRadioButtonId()); boolean checked = checkedRadioButton.isChecked(); } }); //Buttons comprobar = (Button) rootView.findViewById(R.id.button_layer); solucion = (Button) rootView.findViewById(R.id.button_solutionlayer); comprobar.setOnClickListener(new OnClickListener() { public void onClick(View v) { if (v.getId() == R.id.button_layer) { CompruebaRespuesta(); } } }); solucion.setOnClickListener(new OnClickListener() { public void onClick(View v) { if (v.getId() == R.id.button_solutionlayer) { Solucion(); } } }); //Arrays preguntas = getResources().getStringArray(R.array.layer_exercise_questions); respuestas = getResources().getStringArray(R.array.layer_exercise_answers); RANDOM(); pregunta.setText(preguntas[indice]); return rootView; }
From source file:de.blinkt.openvpn.fragments.AboutFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.about, container, false); TextView ver = (TextView) v.findViewById(R.id.version); String version;// w w w . ja v a 2s . c om String name = "Openvpn"; try { PackageInfo packageinfo = getActivity().getPackageManager() .getPackageInfo(getActivity().getPackageName(), 0); version = packageinfo.versionName; name = getString(R.string.app); } catch (NameNotFoundException e) { version = "error fetching version"; } ver.setText(getString(R.string.version_info, name, version)); TextView paypal = (TextView) v.findViewById(R.id.donatestring); String donatetext = getActivity().getString(R.string.donatewithpaypal); Spanned htmltext = Html.fromHtml(donatetext); paypal.setText(htmltext); paypal.setMovementMethod(LinkMovementMethod.getInstance()); gmsTextView = (TextView) v.findViewById(R.id.donategms); /* recreating view without onCreate/onDestroy cycle */ // Disable GMS for now if (mService != null) initGooglePlayDonation(); TextView translation = (TextView) v.findViewById(R.id.translation); // Don't print a text for myself if (getString(R.string.translationby).contains("Arne Schwabe")) translation.setText(""); else translation.setText(R.string.translationby); WebView wv = (WebView) v.findViewById(R.id.webView); wv.loadUrl("file:///android_asset/full_licenses.html"); return v; }
From source file:br.liveo.ndrawer.ui.fragment.MainFragment12.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // TODO Auto-generated method stub rootView = inflater.inflate(R.layout.fragment_main12, container, false); rootView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); // ? ? ? ?? // new PreTracking? ArrayList // ?? ? ? ? /*for(int i = 0; i < 5; i++){ String transI = String.valueOf(i); PreTracking pt = new PreTracking("date"+i, "distance"+i, "time"+i, "addr"+i); mPreTrackingList.add(pt);// w w w. jav a2 s. c o m } // ArrayList ?? mPreTrackingAdapter.setPreTrackingList(mPreTrackingList); ListView list; list = (ListView)rootView.findViewById(R.id.preTracking); list.setAdapter(mPreTrackingAdapter); // ?? ? ? ? ? xml list.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { final String date = mPreTrackingAdapter.getPreTrackingList().get(position).getDate(); final String time = mPreTrackingAdapter.getPreTrackingList().get(position).getTime(); final String distance = mPreTrackingAdapter.getPreTrackingList().get(position).getDistance(); final String address = mPreTrackingAdapter.getPreTrackingList().get(position).getAddress(); Toast toast = Toast.makeText(getContext(), date + "/" + time + "/" + distance + "/" + address, Toast.LENGTH_LONG); toast.show(); } });*/ return rootView; }
From source file:fr.bde_eseo.eseomega.profile.ConnectProfileFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Find layout elements View rootView = inflater.inflate(R.layout.fragment_connect_profile, container, false); getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); //getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); btValid = (Button) rootView.findViewById(R.id.button_disconnect); etUserID = (MaterialEditText) rootView.findViewById(R.id.etUserID); etUserPassword = (MaterialEditText) rootView.findViewById(R.id.etUserPassword); //Utilities.hideSoftKeyboard(getActivity()); // UI's better with that rand = new Random(); // Bullshit/* w ww. j a va 2 s . c o m*/ bullshitHint = getActivity().getResources().getStringArray(R.array.bullshitHintUser); etUserID.setHint(bullshitHint[rand.nextInt(bullshitHint.length)]); // Listener on validation button btValid.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (etUserID.getText().toString().length() < 1) { etUserID.setError("Vous ne savez pas quoi mettre ?"); } else if (etUserPassword.getText().toString().length() < 1) { etUserPassword.setError("Un trou de mmoire ? Mmh ..."); } else { AsyncLogin asyncLogin = new AsyncLogin(getActivity()); asyncLogin.execute(); } etUserID.setHint(bullshitHint[rand.nextInt(bullshitHint.length)]); } }); return rootView; }
From source file:org.thomasamsler.android.flashcards.fragment.SetupFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.setup_fragment, container, false); }