List of usage examples for android.view ViewGroup findViewById
@Nullable public final <T extends View> T findViewById(@IdRes int id)
From source file:com.tobolkac.triviaapp.ScreenSlidePageFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { numQuestions = ac.getNumPages();/*from ww w. j a va2s . com*/ Log.d("a", "XXXcreateXXX"); // resetTimer(); // Inflate the layout containing a title and body text. ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_screen_slide_page, container, false); // Set the title view to show the page number. ((TextView) rootView.findViewById(android.R.id.text1)) .setText("Question " + (mPageNumber + 1) + " of " + numQuestions); //ProgressButton b = (ProgressButton) getActivity().findViewById(R.id.progressButton1); //b.setProgress(50); // questionTimerTextView = (TextView) rootView.findViewById(R.id.questionTimer); TextView question = (TextView) rootView.findViewById(R.id.questionText); question.setText(questionString); Button answer1Button = (Button) rootView.findViewById(R.id.answer1Button); answer1Button.setText(answersArray[0]); Button answer2Button = (Button) rootView.findViewById(R.id.answer2Button); answer2Button.setText(answersArray[1]); Button answer3Button = (Button) rootView.findViewById(R.id.answer3Button); answer3Button.setText(answersArray[2]); Button answer4Button = (Button) rootView.findViewById(R.id.answer4Button); answer4Button.setText(answersArray[3]); numberCorrectText = (TextView) getActivity().findViewById(R.id.numberCorrect); numberCorrectText.setText("" + numCorrect); Log.d("oo", "" + answer1Button.getTextSize()); if (answersArray[0].length() > 22) { answer1Button.setTextSize(12); } if (answersArray[1].length() > 22) { answer2Button.setTextSize(12); } if (answersArray[2].length() > 22) { answer3Button.setTextSize(12); } if (answersArray[3].length() > 22) { answer4Button.setTextSize(12); } answer1Button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ac.setLagMillis(); // questionTimerHandler.removeCallbacks(questionTimerRunnable, null); // resetTimer(); //vibrate on button click ac.vibe.vibrate(40); //check against correct and add to correct if (answerCorrect == 1) { numCorrect++; ac.numCorrect++; numberCorrectText.setText("" + numCorrect); ac.correctArray[mPageNumber] = 1; } if (getPageNumber() + 1 == numQuestions) { Toast.makeText(getActivity(), "correct: " + numCorrect + " time: " + ac.getFormattedTime(), Toast.LENGTH_SHORT).show(); ac.evalGame(numCorrect, ac.getTimeInMilliseconds()); // Intent intent = new Intent(getActivity(), MainActivity.class); // startActivity(intent); } ViewPager pager = (ViewPager) getActivity().findViewById(R.id.pager); Log.d("page number", "page number: " + (getPageNumber())); pager.setCurrentItem(getPageNumber() + 1); } }); answer2Button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ac.setLagMillis(); //vibrate on button click ac.vibe.vibrate(40); //check against correct and add to correct if (answerCorrect == 2) { numCorrect++; ac.numCorrect++; numberCorrectText.setText("" + numCorrect); ac.correctArray[mPageNumber] = 1; } if (getPageNumber() + 1 == numQuestions) { Toast.makeText(getActivity(), "correct: " + numCorrect + " time: " + ac.getFormattedTime(), Toast.LENGTH_SHORT).show(); ac.evalGame(numCorrect, ac.getTimeInMilliseconds()); // Intent intent = new Intent(getActivity(), MainActivity.class); // startActivity(intent); } ViewPager pager = (ViewPager) getActivity().findViewById(R.id.pager); Log.d("page number", "page number: " + (getPageNumber())); pager.setCurrentItem(getPageNumber() + 1); } }); answer3Button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ac.setLagMillis(); //vibrate on button click ac.vibe.vibrate(40); //check against correct and add to correct if (answerCorrect == 3) { numCorrect++; ac.numCorrect++; numberCorrectText.setText("" + numCorrect); ac.correctArray[mPageNumber] = 1; } if (getPageNumber() + 1 == numQuestions) { Toast.makeText(getActivity(), "correct: " + numCorrect + " time: " + ac.getFormattedTime(), Toast.LENGTH_SHORT).show(); ac.evalGame(numCorrect, ac.getTimeInMilliseconds()); // Intent intent = new Intent(getActivity(), MainActivity.class); // startActivity(intent); } ViewPager pager = (ViewPager) getActivity().findViewById(R.id.pager); Log.d("page number", "page number: " + (getPageNumber())); pager.setCurrentItem(getPageNumber() + 1); } }); answer4Button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ac.setLagMillis(); //vibrate on button click ac.vibe.vibrate(40); //check against correct and add to correct if (answerCorrect == 4) { numCorrect++; ac.numCorrect++; numberCorrectText.setText("" + numCorrect); ac.correctArray[mPageNumber] = 1; } if (getPageNumber() + 1 == numQuestions) { Toast.makeText(getActivity(), "correct: " + numCorrect + " time: " + ac.getFormattedTime(), Toast.LENGTH_SHORT).show(); ac.evalGame(numCorrect, ac.getTimeInMilliseconds()); // Intent intent = new Intent(getActivity(), MainActivity.class); // startActivity(intent); } ViewPager pager = (ViewPager) getActivity().findViewById(R.id.pager); Log.d("page number", "page number: " + (getPageNumber())); pager.setCurrentItem(getPageNumber() + 1); } }); return rootView; }
From source file:fr.shywim.antoinedaniel.ui.fragment.SoundPagerFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_soundpager, container, false); UiUtils.setStatusBarBackground(root, getResources()); mPager = (ViewPager) root.findViewById(R.id.pager); mPager.setAdapter(new CollectionPagerAdapter(getChildFragmentManager())); Toolbar toolbar = (Toolbar) root.findViewById(R.id.toolbar_actionbar); toolbar.setTitle(R.string.drawer_sounds); ((FragmentsCallbacks) mActivity).setActionBarToolbar(toolbar); mFab = root.findViewById(R.id.fab_settings); setupFabButton();//from ww w .java2s . c om return root; }
From source file:com.artemchep.horario.ui.fragments.details.TeacherDetailsFragment.java
@Override protected ViewGroup onCreateContentView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @NonNull List<ContentItem<Teacher>> contentItems, @Nullable Bundle savedInstanceState) { getToolbar().inflateMenu(R.menu.details_teacher); ViewGroup vg = (ViewGroup) inflater.inflate(R.layout.fragment_details_teacher, container, false); initWithFab(R.id.action_edit, R.drawable.ic_pencil_white_24dp); mNoteContainer = vg.findViewById(R.id.info_container); mPhoneContainer = vg.findViewById(R.id.phone_container); mPhoneContainer.setOnClickListener(new View.OnClickListener() { @Override/*from ww w .j ava2 s . co m*/ public void onClick(View view) { if (TextUtils.isEmpty(mModel.phone)) { Timber.tag(TAG).w("Tried to copy an empty phone!"); return; } // Copy email to clipboard ClipboardManager clipboard = (ClipboardManager) getContext() .getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText(mModel.phone, mModel.phone); // TODO: More informative description of the clip clipboard.setPrimaryClip(clip); // Show toast message String msg = getString(R.string.details_phone_clipboard, mModel.phone); Toasty.info(getContext(), msg).show(); } }); mEmailContainer = vg.findViewById(R.id.email_container); mEmailContainer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (TextUtils.isEmpty(mModel.email)) { Timber.tag(TAG).w("Tried to copy an empty email!"); return; } // Copy email to clipboard ClipboardManager clipboard = (ClipboardManager) getContext() .getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText(mModel.email, mModel.email); // TODO: More informative description of the clip clipboard.setPrimaryClip(clip); // Show toast message String msg = getString(R.string.details_email_clipboard, mModel.email); Toasty.info(getContext(), msg).show(); } }); mPhoneButton = (Button) mPhoneContainer.findViewById(R.id.phone_send); mPhoneButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (TextUtils.isEmpty(mModel.phone)) { Timber.tag(TAG).w("Tried to call an empty phone!"); return; } Intent intent = new Intent(Intent.ACTION_DIAL); intent.setData(Uri.parse("tel:" + mModel.phone)); try { startActivity(intent); } catch (ActivityNotFoundException ignored) { } } }); mEmailButton = (Button) mEmailContainer.findViewById(R.id.email_send); mEmailButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (TextUtils.isEmpty(mModel.email)) { Timber.tag(TAG).w("Tried to send to an empty email!"); return; } String[] recipients = { mModel.email }; Intent intent = new Intent().putExtra(Intent.EXTRA_EMAIL, recipients); intent.setAction(Intent.ACTION_SENDTO); intent.setData(Uri.parse("mailto:")); // only email apps should handle it try { startActivity(intent); } catch (ActivityNotFoundException e) { // TODO:!!!!! String msg = "No email app"; //getString(R.string.feedback_error_no_app); Toasty.info(getContext(), msg).show(); } } }); mNoteTextView = (TextView) mNoteContainer.findViewById(R.id.info); mEmailTextView = (TextView) mEmailContainer.findViewById(R.id.email); mPhoneTextView = (TextView) mPhoneContainer.findViewById(R.id.phone); // Note contentItems.add(new ContentItem<Teacher>() { @Override public void onSet(@Nullable Teacher model) { if (model == null || TextUtils.isEmpty(model.info)) { mNoteContainer.setVisibility(View.GONE); } else { mNoteContainer.setVisibility(View.VISIBLE); mNoteTextView.setText(model.info); } } @Override public boolean hasChanged(@Nullable Teacher old, @Nullable Teacher model) { String a = old != null ? old.info : null; String b = model != null ? model.info : null; return !TextUtils.equals(a, b); } }); // Email contentItems.add(new ContentItem<Teacher>() { @Override public void onSet(@Nullable Teacher model) { if (model == null || TextUtils.isEmpty(model.email)) { mEmailContainer.setVisibility(View.GONE); } else { mEmailContainer.setVisibility(View.VISIBLE); mEmailTextView.setText(model.info); if (PatternUtils.isEmail(model.email)) { mEmailButton.setVisibility(View.VISIBLE); } else mEmailButton.setVisibility(View.GONE); } } @Override public boolean hasChanged(@Nullable Teacher old, @Nullable Teacher model) { String a = old != null ? old.email : null; String b = model != null ? model.email : null; return !TextUtils.equals(a, b); } }); // Phone contentItems.add(new ContentItem<Teacher>() { @Override public void onSet(@Nullable Teacher model) { if (model == null || TextUtils.isEmpty(model.phone)) { mPhoneContainer.setVisibility(View.GONE); } else { mPhoneContainer.setVisibility(View.VISIBLE); mPhoneTextView.setText(model.phone); if (PatternUtils.isPhone(model.phone)) { mPhoneButton.setVisibility(View.VISIBLE); } else mPhoneButton.setVisibility(View.GONE); } } @Override public boolean hasChanged(@Nullable Teacher old, @Nullable Teacher model) { String a = old != null ? old.phone : null; String b = model != null ? model.phone : null; return !TextUtils.equals(a, b); } }); return vg; }
From source file:com.adithya321.sharesanalysis.fragments.SharePurchaseFragment.java
@Nullable @Override//from w ww .j a v a2 s. c om public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_share_purchase, container, false); databaseHandler = new DatabaseHandler(getContext()); sharePurchasesRecyclerView = (RecyclerView) root.findViewById(R.id.share_purchases_recycler_view); emptyTV = (TextView) root.findViewById(R.id.empty); arrow = (ImageView) root.findViewById(R.id.arrow); setRecyclerViewAdapter(); FloatingActionButton addPurchaseFab = (FloatingActionButton) root.findViewById(R.id.add_purchase_fab); addPurchaseFab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final Dialog dialog = new Dialog(getContext()); dialog.setTitle("Add Share Purchase"); dialog.setContentView(R.layout.dialog_add_share_purchase); dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT); dialog.show(); final AutoCompleteTextView name = (AutoCompleteTextView) dialog.findViewById(R.id.share_name); List<String> nseList = ShareUtils.getNseList(getContext()); FilterWithSpaceAdapter<String> arrayAdapter = new FilterWithSpaceAdapter<>(getContext(), android.R.layout.simple_dropdown_item_1line, nseList); name.setThreshold(1); name.setAdapter(arrayAdapter); final Spinner spinner = (Spinner) dialog.findViewById(R.id.existing_spinner); ArrayList<String> shares = new ArrayList<>(); for (Share share : sharesList) { shares.add(share.getName()); } ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_item, shares); spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(spinnerAdapter); final RadioButton newRB = (RadioButton) dialog.findViewById(R.id.radioBtn_new); RadioButton existingRB = (RadioButton) dialog.findViewById(R.id.radioBtn_existing); if (shares.size() == 0) existingRB.setVisibility(View.GONE); (newRB).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { name.setVisibility(View.VISIBLE); spinner.setVisibility(View.GONE); } }); (existingRB).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { name.setVisibility(View.GONE); spinner.setVisibility(View.VISIBLE); } }); Calendar calendar = Calendar.getInstance(); year_start = calendar.get(Calendar.YEAR); month_start = calendar.get(Calendar.MONTH) + 1; day_start = calendar.get(Calendar.DAY_OF_MONTH); final Button selectDate = (Button) dialog.findViewById(R.id.select_date); selectDate.setText(new StringBuilder().append(day_start).append("/").append(month_start).append("/") .append(year_start)); selectDate.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Dialog dialog = new DatePickerDialog(getActivity(), onDateSetListener, year_start, month_start - 1, day_start); dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { selectDate.setText(new StringBuilder().append(day_start).append("/") .append(month_start).append("/").append(year_start)); } }); dialog.show(); } }); Button addPurchaseBtn = (Button) dialog.findViewById(R.id.add_purchase_btn); addPurchaseBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Share share = new Share(); share.setId(databaseHandler.getNextKey("share")); share.setPurchases(new RealmList<Purchase>()); Purchase purchase = new Purchase(); purchase.setId(databaseHandler.getNextKey("purchase")); if (newRB.isChecked()) { String sName = name.getText().toString().trim(); if (sName.equals("")) { Toast.makeText(getActivity(), "Invalid Name", Toast.LENGTH_SHORT).show(); return; } else { share.setName(sName); purchase.setName(sName); } } String stringStartDate = year_start + " " + month_start + " " + day_start; DateFormat format = new SimpleDateFormat("yyyy MM dd", Locale.ENGLISH); try { Date date = format.parse(stringStartDate); share.setDateOfInitialPurchase(date); purchase.setDate(date); } catch (Exception e) { Toast.makeText(getActivity(), "Invalid Date", Toast.LENGTH_SHORT).show(); return; } EditText quantity = (EditText) dialog.findViewById(R.id.no_of_shares); try { purchase.setQuantity(Integer.parseInt(quantity.getText().toString())); } catch (Exception e) { Toast.makeText(getActivity(), "Invalid Number of Shares", Toast.LENGTH_SHORT).show(); return; } EditText price = (EditText) dialog.findViewById(R.id.buying_price); try { purchase.setPrice(Double.parseDouble(price.getText().toString())); } catch (Exception e) { Toast.makeText(getActivity(), "Invalid Buying Price", Toast.LENGTH_SHORT).show(); return; } purchase.setType("buy"); if (newRB.isChecked()) { if (!databaseHandler.addShare(share, purchase)) { Toast.makeText(getActivity(), "Share Already Exists", Toast.LENGTH_SHORT).show(); return; } } else { purchase.setName(spinner.getSelectedItem().toString()); databaseHandler.addPurchase(spinner.getSelectedItem().toString(), purchase); } setRecyclerViewAdapter(); dialog.dismiss(); } }); } }); return root; }
From source file:com.rsmsa.accapp.ScreenSlidePageFragmentTwo.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.vehicle_two, container, false); tab_one = (EditText) rootView.findViewById(R.id.dob_one); vehicle_category = (Spinner) rootView.findViewById(R.id.vtype_spinner); vehicle_type = (Button) rootView.findViewById(R.id.vehicle_type_select_button); /**//from w w w.ja va 2 s.c om * 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); final RadioButton male = (RadioButton) rootView.findViewById(R.id.male); final 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 = (CheckBox) rootView.findViewById(R.id.drug_edit); phone_use = (CheckBox) rootView.findViewById(R.id.phone_edit); seat_belt = (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); /** * getting values of our view elements */ drug.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (((CheckBox) v).isChecked()) { MainActivity.V2_drug_edit = "Drugs Use"; } else { MainActivity.V2_drug_edit = " No Drug use"; } } }); phone_use.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (((CheckBox) v).isChecked()) { MainActivity.V2_phone_edit = "Was using Phone"; } else { MainActivity.V2_phone_edit = " No phone use"; } } }); seat_belt.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (((CheckBox) v).isChecked()) { MainActivity.V2_seat_belt_edit = "Seat belt not fastened"; } else { MainActivity.V2_seat_belt_edit = "Seat belt fastened"; } } }); male.setChecked(true); // Fatal.setChecked(true); male.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { if (b == true) { female.setChecked(false); MainActivity.V2_gender = "male"; } } }); female.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { if (b == true) { male.setChecked(false); MainActivity.V2_gender = "female"; } } }); 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; } @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:io.syng.activity.BaseActivity.java
@SuppressLint("InflateParams") @Override/* w ww . ja va 2 s .c o m*/ public void setContentView(final int layoutResID) { LayoutInflater inflater = getLayoutInflater(); mDrawerLayout = (DrawerLayout) inflater.inflate(R.layout.drawer, null, false); super.setContentView(mDrawerLayout); FrameLayout content = (FrameLayout) findViewById(R.id.content); ViewGroup inflated = (ViewGroup) inflater.inflate(layoutResID, content, true); topToolbar = (Toolbar) inflated.findViewById(R.id.app_toolbar); if (topToolbar != null) { setSupportActionBar(topToolbar); mDrawerLayout.setStatusBarBackgroundColor(ContextCompat.getColor(this, android.R.color.black)); } mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, topToolbar, R.string.drawer_open, R.string.drawer_close) { @Override public void onDrawerClosed(View drawerView) { super.onDrawerClosed(drawerView); GeneralUtil.hideKeyBoard(mSearchTextView, BaseActivity.this); mDAppsDrawerAdapter.setEditModeEnabled(false); mProfileDrawerAdapter.setEditModeEnabled(false); if (!isDrawerFrontViewActive()) { flipDrawer(); } } }; mDrawerLayout.setDrawerListener(mDrawerToggle); mSearchTextView = (EditText) findViewById(R.id.search); initSearch(); findViewById(R.id.ll_settings).setOnClickListener(this); findViewById(R.id.ll_contribute).setOnClickListener(this); findViewById(R.id.drawer_header_item).setOnClickListener(this); findViewById(R.id.drawer_header_item).setOnLongClickListener(this); mFrontView = findViewById(R.id.ll_front_view); mBackView = findViewById(R.id.ll_back_view); RecyclerView profilesRecyclerView = (RecyclerView) findViewById(R.id.profile_drawer_recycler_view); RecyclerView.LayoutManager layoutManager2 = new LinearLayoutManager(this); profilesRecyclerView.setLayoutManager(layoutManager2); mProfileDrawerAdapter = new ProfileDrawerAdapter(this, this, new ProfileDrawerAdapter.OnStartDragListener() { @Override public void onStartDrag(RecyclerView.ViewHolder viewHolder) { mProfilesTouchHelper.startDrag(viewHolder); } }); profilesRecyclerView.setAdapter(mProfileDrawerAdapter); ItemTouchHelper.Callback profilesCallback = new SimpleItemTouchHelperCallback(mProfileDrawerAdapter); mProfilesTouchHelper = new ItemTouchHelper(profilesCallback); mProfilesTouchHelper.attachToRecyclerView(profilesRecyclerView); updateCurrentProfileName(); populateProfiles(); RecyclerView dAppsRecyclerView = (RecyclerView) findViewById(R.id.dapp_drawer_recycler_view); dAppsRecyclerView.setHasFixedSize(true); RecyclerView.LayoutManager layoutManager1 = new LinearLayoutManager(this); dAppsRecyclerView.setLayoutManager(layoutManager1); mDAppsDrawerAdapter = new DAppDrawerAdapter(this, this, new DAppDrawerAdapter.OnStartDragListener() { @Override public void onStartDrag(RecyclerView.ViewHolder viewHolder) { mDAppsTouchHelper.startDrag(viewHolder); } }); dAppsRecyclerView.setAdapter(mDAppsDrawerAdapter); ItemTouchHelper.Callback dAppsCallback = new SimpleItemTouchHelperCallback(mDAppsDrawerAdapter); mDAppsTouchHelper = new ItemTouchHelper(dAppsCallback); mDAppsTouchHelper.attachToRecyclerView(dAppsRecyclerView); populateDApps(); mHeaderImageView = (ImageView) findViewById(R.id.iv_header); Glide.with(this).load(ProfileManager.getCurrentProfileBackgroundResourceId()).into(mHeaderImageView); GeneralUtil.showWarningDialogIfNeed(this); ProfileManager.setProfilesChangeListener(this); }
From source file:io.vit.vitio.Fragments.SubjectView.SubjectViewFragment.java
private void init(ViewGroup rootView) { //Get Arguments try {//from ww w .j a v a2s. c om MY_CLASS_NUMBER = getArguments().getString("class_number"); } catch (Exception e) { e.printStackTrace(); Toast.makeText(getActivity(), "Error", Toast.LENGTH_SHORT).show(); getActivity().finish(); } //Initialize TextViews subName = (TextView) rootView.findViewById(R.id.subject_name); subType = (TextView) rootView.findViewById(R.id.subject_type); subCode = (TextView) rootView.findViewById(R.id.subject_code); subSlot = (TextView) rootView.findViewById(R.id.subject_slot); subVenue = (TextView) rootView.findViewById(R.id.subject_venue); subPer = (TextView) rootView.findViewById(R.id.subject_perc); subFaculty = (TextView) rootView.findViewById(R.id.subject_faculty); //subSchool = (TextView) rootView.findViewById(R.id.subject_school); attended = (TextView) rootView.findViewById(R.id.subject_att_out_total); attendClassText = (TextView) rootView.findViewById(R.id.attend_class_text); missClassText = (TextView) rootView.findViewById(R.id.miss_class_text); //Initialize ImageViews subColorCircle = (ImageView) rootView.findViewById(R.id.subject_color_circle); missMinus = (LinearLayout) rootView.findViewById(R.id.miss_minus); missAdd = (LinearLayout) rootView.findViewById(R.id.miss_plus); attendMinus = (LinearLayout) rootView.findViewById(R.id.attend_minus); attendAdd = (LinearLayout) rootView.findViewById(R.id.attend_plus); back_button = (ImageView) rootView.findViewById(R.id.back_button); schoolImage = (ImageView) rootView.findViewById(R.id.school_image); //Initialize LinearLayouts attBar = (LinearLayout) rootView.findViewById(R.id.subject_per_bar); //Initialize Others attFab = (FloatingActionButton) rootView.findViewById(R.id.att_fab); marksFab = (FloatingActionButton) rootView.findViewById(R.id.marks_fab); reminderFab = (FloatingActionButton) rootView.findViewById(R.id.reminder_fab); dataHandler = DataHandler.getInstance(getActivity()); }
From source file:com.android.messaging.ui.conversationlist.ConversationListFragment.java
/** * {@inheritDoc} from Fragment//from w w w . ja v a 2 s . c om */ @Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.conversation_list_fragment, container, false); mRecyclerView = (RecyclerView) rootView.findViewById(android.R.id.list); mEmptyListMessageView = (ListEmptyView) rootView.findViewById(R.id.no_conversations_view); mEmptyListMessageView.setImageHint(R.drawable.ic_oobe_conv_list); // The default behavior for default layout param generation by LinearLayoutManager is to // provide width and height of WRAP_CONTENT, but this is not desirable for // ConversationListFragment; the view in each row should be a width of MATCH_PARENT so that // the entire row is tappable. final Activity activity = getActivity(); final LinearLayoutManager manager = new LinearLayoutManager(activity) { @Override public RecyclerView.LayoutParams generateDefaultLayoutParams() { return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); } }; mRecyclerView.setLayoutManager(manager); mRecyclerView.setHasFixedSize(true); mRecyclerView.setAdapter(mAdapter); mRecyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() { int mCurrentState = AbsListView.OnScrollListener.SCROLL_STATE_IDLE; @Override public void onScrolled(final RecyclerView recyclerView, final int dx, final int dy) { if (mCurrentState == AbsListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL || mCurrentState == AbsListView.OnScrollListener.SCROLL_STATE_FLING) { ImeUtil.get().hideImeKeyboard(getActivity(), mRecyclerView); } if (isScrolledToFirstConversation()) { setScrolledToNewestConversationIfNeeded(); } else { mListBinding.getData().setScrolledToNewestConversation(false); } } @Override public void onScrollStateChanged(final RecyclerView recyclerView, final int newState) { mCurrentState = newState; } }); mRecyclerView.addOnItemTouchListener(new ConversationListSwipeHelper(mRecyclerView)); if (savedInstanceState != null) { mListState = savedInstanceState.getParcelable(SAVED_INSTANCE_STATE_LIST_VIEW_STATE_KEY); } mStartNewConversationButton = (ImageView) rootView.findViewById(R.id.start_new_conversation_button); if (mArchiveMode) { mStartNewConversationButton.setVisibility(View.GONE); } else { mStartNewConversationButton.setVisibility(View.VISIBLE); mStartNewConversationButton.setOnClickListener(new OnClickListener() { @Override public void onClick(final View clickView) { mHost.onCreateConversationClick(); } }); } ViewCompat.setTransitionName(mStartNewConversationButton, BugleAnimationTags.TAG_FABICON); // The root view has a non-null background, which by default is deemed by the framework // to be a "transition group," where all child views are animated together during an // activity transition. However, we want each individual items in the recycler view to // show explode animation themselves, so we explicitly tag the root view to be a non-group. ViewGroupCompat.setTransitionGroup(rootView, false); setHasOptionsMenu(true); return rootView; }
From source file:org.alfresco.mobile.android.application.ui.form.FormManager.java
private void createPropertyFields(FieldGroupConfig group, ViewGroup hookView, LayoutInflater li, boolean isEdition) { ViewGroup groupview = hookView;/*w ww . j av a 2 s .co m*/ ViewGroup grouprootview = null; // Header if (!TextUtils.isEmpty(group.getLabel())) { grouprootview = (ViewGroup) li.inflate(R.layout.form_header, null); TextView tv = (TextView) grouprootview.findViewById(R.id.title); tv.setText(group.getLabel()); groupview = (ViewGroup) grouprootview.findViewById(R.id.group_panel); hookView.addView(grouprootview); } // For each properties, display the line associated for (FieldConfig fieldConfig : group.getItems()) { if (fieldConfig instanceof FieldGroupConfig) { createPropertyFields((FieldGroupConfig) fieldConfig, groupview, li, isEdition); continue; } // Retrieve the Field builder based on config Property nodeProp = node.getProperty(fieldConfig.getModelIdentifier()); View fieldView = null; BaseField field = generateField(nodeProp, fieldConfig, groupview, isEdition); if (field == null) { continue; } fieldsOrderIndex.add(field); fieldsIndex.put(fieldConfig.getModelIdentifier(), field); // Mark All fields in edition mode if (isEdition) { // Mark required Field if (field.isRequired()) { mandatoryFields.add(field); } } // If requires fragment for pickers. if (field.isPickerRequired()) { field.setFragment(fr); } if (field.requireExtra()) { Bundle b = new Bundle(); b.putSerializable(PathField.EXTRA_PARENT_FOLDER, parentFolder); field.setExtra(b); } // If requires Async if (field.requireAsync() && !modelRequested.contains(fieldConfig.getModelIdentifier())) { String requestId = Operator.with(getActivity()).load(field.requestData(node)); RequestHolder holder = new RequestHolder(field, fieldConfig.getModelIdentifier(), requestId); modelRequested.add(fieldConfig.getModelIdentifier()); operationFieldIndex.put(requestId, holder); } } if (groupview.getChildCount() == 0 && grouprootview != null) { grouprootview.setVisibility(View.GONE); } }
From source file:com.google.android.apps.iosched.ui.MyScheduleFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_list_with_empty_container, container, false);/* w w w. j av a 2 s .c o m*/ inflater.inflate(R.layout.empty_waiting_for_sync, (ViewGroup) root.findViewById(android.R.id.empty), true); root.setBackgroundColor(Color.WHITE); ListView listView = (ListView) root.findViewById(android.R.id.list); listView.setItemsCanFocus(true); listView.setCacheColorHint(Color.WHITE); listView.setSelector(android.R.color.transparent); //listView.setEmptyView(root.findViewById(android.R.id.empty)); return root; }