List of usage examples for android.widget LinearLayout setOnClickListener
public void setOnClickListener(@Nullable OnClickListener l)
From source file:com.example.tuicool.MainActivity.java
private void initDrawer() { mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawer = (ListView) findViewById(R.id.start_drawer); mDrawerLayout.setDrawerListener(new DemoDrawerListener()); // HeaderViewFooterView listviewsetAdapter() View drawer_HeaderView = getLayoutInflater().inflate(R.layout.drawer_headerview, null); mDrawer.addHeaderView(drawer_HeaderView); LinearLayout mDrawerHeader = (LinearLayout) drawer_HeaderView.findViewById(R.id.left_login_bar); mDrawerHeader.setOnClickListener(this); View drawer_FooterView = getLayoutInflater().inflate(R.layout.drawer_footerview, null); mDrawer.addFooterView(drawer_FooterView, null, false); footV_layout_nightModel = (RelativeLayout) drawer_FooterView.findViewById(R.id.footV_layout_nightModel); footV_layout_nightModel.setOnClickListener(this); // tv_drawer_footV_nightModel = (TextView) drawer_FooterView.findViewById(R.id.tv_drawer_footV_nightModel); drawer_FooterView.findViewById(R.id.footV_layout_offline_download).setOnClickListener(this); drawer_FooterView.findViewById(R.id.footV_layout_settings).setOnClickListener(this); mDrawerLayout.setDrawerTitle(GravityCompat.START, getString(R.string.drawer_title)); mDrawer.setAdapter(new DrawerAdapter()); // listview/*from w ww . j a v a2 s . c om*/ mDrawer.setTextFilterEnabled(true); mDrawer.setChoiceMode(ListView.CHOICE_MODE_SINGLE); // Start with first item activated. // Make the newly clicked item the currently selected one. mDrawer.setItemChecked(0, true); mDrawer.setOnItemClickListener(new DrawerItemClickListener()); }
From source file:com.xengar.android.englishverbs.ui.DetailsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_details); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);/*from w ww . ja v a2 s. co m*/ getSupportActionBar().setDisplayHomeAsUpEnabled(true); Bundle bundle = getIntent().getExtras(); demo = bundle.getBoolean(DEMO_MODE, false); verbID = bundle.getLong(VERB_ID, -1); String title = bundle.getString(VERB_NAME); getSupportActionBar().setTitle(title); // Invalidate the options menu, so the "Edit" menu option can be hidden. invalidateOptionsMenu(); //Text infinitive = (TextView) findViewById(R.id.infinitive); simplePast = (TextView) findViewById(R.id.simple_past); pastParticiple = (TextView) findViewById(R.id.past_participle); pInfinitive = (TextView) findViewById(R.id.phonetic_infinitive); pSimplePast = (TextView) findViewById(R.id.phonetic_simple_past); pPastParticiple = (TextView) findViewById(R.id.phonetic_past_participle); definition = (TextView) findViewById(R.id.definition); translation = (TextView) findViewById(R.id.translation); sample1 = (TextView) findViewById(R.id.sample1); sample2 = (TextView) findViewById(R.id.sample2); sample3 = (TextView) findViewById(R.id.sample3); // define click listeners LinearLayout header = (LinearLayout) findViewById(R.id.play_infinitive); header.setOnClickListener(this); header = (LinearLayout) findViewById(R.id.play_simple_past); header.setOnClickListener(this); header = (LinearLayout) findViewById(R.id.play_past_participle); header.setOnClickListener(this); // initialize Speaker tts = new TextToSpeech(this, new TextToSpeech.OnInitListener() { @Override public void onInit(int status) { if (status == TextToSpeech.SUCCESS) { int result = tts.setLanguage(Locale.US); if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) { if (LOG) { Log.e("TTS", "This Language is not supported"); } } } else { if (LOG) { Log.e("TTS", "Initilization Failed!"); } } } }); // Initialize a loader to read the verb data from the database and display it getLoaderManager().initLoader(EXISTING_VERB_LOADER, null, this); showFavoriteButtons(); // Obtain the FirebaseAnalytics instance. mFirebaseAnalytics = FirebaseAnalytics.getInstance(this); ActivityUtils.firebaseAnalyticsLogEventSelectContent(mFirebaseAnalytics, PAGE_VERB_DETAILS, PAGE_VERB_DETAILS, TYPE_PAGE); // create AdMob banner listener = new LogAdListener(mFirebaseAnalytics, DETAILS_ACTIVITY); mAdView = ActivityUtils.createAdMobBanner(this, listener); if (demo) { defineDemoMode(); } }
From source file:com.todoroo.astrid.actfm.TagViewFragment.java
private void setUpMembersGallery() { LinearLayout membersView = (LinearLayout) getView().findViewById(R.id.shared_with); membersView.setOnClickListener(settingsListener); try {//ww w . ja v a 2s . c o m String membersString = tagData.getValue(TagData.MEMBERS); JSONArray members = new JSONArray(membersString); if (members.length() > 0) { membersView.setOnClickListener(null); membersView.removeAllViews(); for (int i = 0; i < members.length(); i++) { JSONObject member = members.getJSONObject(i); addImageForMember(membersView, member); } // Handle creator JSONObject owner; if (tagData.getValue(TagData.USER_ID) != 0) { owner = new JSONObject(tagData.getValue(TagData.USER)); } else { owner = ActFmPreferenceService.thisUser(); } addImageForMember(membersView, owner); JSONObject unassigned = new JSONObject(); unassigned.put("id", Task.USER_ID_UNASSIGNED); //$NON-NLS-1$ unassigned.put("name", getActivity().getString(R.string.actfm_EPA_unassigned)); //$NON-NLS-1$ addImageForMember(membersView, unassigned); } } catch (JSONException e) { e.printStackTrace(); } getView().findViewById(R.id.filter_assigned).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { resetAssignedFilter(); } }); }
From source file:org.glucosio.android.fragment.HistoryFragment.java
private void showBottomSheetDialog(final View itemView) { mBottomSheetDialog = new BottomSheetDialog(getActivity()); View sheetView = getActivity().getLayoutInflater().inflate(R.layout.fragment_history_bottom_sheet, null); LinearLayout edit = (LinearLayout) sheetView.findViewById(R.id.fragment_history_bottom_sheet_edit); LinearLayout delete = (LinearLayout) sheetView.findViewById(R.id.fragment_history_bottom_sheet_delete); final TextView idTextView = (TextView) itemView.findViewById(R.id.item_history_id); edit.setOnClickListener(new View.OnClickListener() { @Override/* w ww. jav a 2s . c o m*/ public void onClick(View v) { int historyTypePosition = (int) historySpinner.getSelectedItemId(); Intent intent; switch (historyTypePosition) { // HAB1C case 1: intent = new Intent(getActivity(), AddA1CActivity.class); break; // Cholesterol case 2: intent = new Intent(getActivity(), AddCholesterolActivity.class); break; // Pressure case 3: intent = new Intent(getActivity(), AddPressureActivity.class); break; // Ketone case 4: intent = new Intent(getActivity(), AddKetoneActivity.class); break; // Weight case 5: intent = new Intent(getActivity(), AddWeightActivity.class); break; // Glucose default: intent = new Intent(getActivity(), AddGlucoseActivity.class); break; } intent.putExtra(INTENT_EXTRA_EDITING_ID, Long.parseLong(idTextView.getText().toString())); intent.putExtra(INTENT_EXTRA_EDITING, true); intent.putExtra(INTENT_EXTRA_DROPDOWN, historyDropdownPosition); // History page is 1 intent.putExtra(INTENT_EXTRA_PAGER, 1); startActivity(intent); mBottomSheetDialog.dismiss(); getActivity().finish(); } }); delete.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mBottomSheetDialog.dismiss(); TextView idTextView = (TextView) itemView.findViewById(R.id.item_history_id); final long idToDelete = Long.parseLong(idTextView.getText().toString()); final CardView item = (CardView) itemView.findViewById(R.id.item_history); item.animate().alpha(0.0f).setDuration(2000); Snackbar.make(((MainActivity) getActivity()).getFabView(), R.string.fragment_history_snackbar_text, Snackbar.LENGTH_SHORT).setCallback(new Snackbar.Callback() { @Override public void onDismissed(Snackbar snackbar, int event) { switch (event) { case Snackbar.Callback.DISMISS_EVENT_ACTION: // Do nothing, see Undo onClickListener break; case Snackbar.Callback.DISMISS_EVENT_TIMEOUT: presenter.onDeleteClicked(idToDelete, historySpinner.getSelectedItemPosition()); break; default: break; } } }).setAction("UNDO", new View.OnClickListener() { @Override public void onClick(View v) { item.clearAnimation(); item.setAlpha(1.0f); mAdapter.notifyDataSetChanged(); } }).setActionTextColor(getResources().getColor(R.color.glucosio_accent)).show(); } }); mBottomSheetDialog.setContentView(sheetView); mBottomSheetDialog.show(); mBottomSheetDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { mBottomSheetDialog = null; } }); }
From source file:com.ess.tudarmstadt.de.sleepsense.mgraph.GraphPlotFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); setHasOptionsMenu(true);/* w w w. j a v a 2 s .c o m*/ Button cookBtn = (Button) rootView.findViewById(R.id.cook_up); cookBtn.setVisibility(View.GONE); cookBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { CookTraffic mCook = new CookTraffic(getActivity().getApplicationContext()); mCook.cookUp(); } }); Button refrBtn = (Button) rootView.findViewById(R.id.refresh_btn); refrBtn.setVisibility(View.GONE); refrBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { redrawCharts(getCurrentDate()); } }); Button clearDB = (Button) rootView.findViewById(R.id.clear_all); clearDB.setVisibility(View.GONE); clearDB.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // clearAllCharts(); // clearDb(); } }); // data_line = new ArrayList<GraphViewData>(); // data_bar = new ArrayList<GraphViewData>(); TextView atDate = (TextView) rootView.findViewById(R.id.at_date); atDate.setText(getCurrentDate()); Button backBtn = (Button) rootView.findViewById(R.id.date_back); backBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dateBackAndForth(true); } }); Button forthBtn = (Button) rootView.findViewById(R.id.date_next); forthBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dateBackAndForth(false); } }); redrawCharts(getDate(-2, getCurrentDate())); LinearLayout layout_light = (LinearLayout) rootView.findViewById(R.id.light_graph); LinearLayout layout_motion = (LinearLayout) rootView.findViewById(R.id.motion_graph); layout_light.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // openBig(); } }); layout_motion.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // openBig(); } }); }
From source file:de.tudarmstadt.dvs.myhealthassistant.myhealthhub.fragments.GraphPlotFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); setHasOptionsMenu(true);// w w w . j av a2s . c o m data_line = new ArrayList<GraphViewData>(); data_bar = new ArrayList<GraphViewData>(); CheckBox box = (CheckBox) rootView.findViewById(R.id.start_record); box.setVisibility(View.GONE); Button refrBtn = (Button) rootView.findViewById(R.id.refresh_btn); refrBtn.setVisibility(View.GONE); refrBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { CookTraffic mCook = new CookTraffic(getActivity().getApplicationContext()); mCook.cookUp(); // clearAllCharts(); // clearDb(((TextView) rootView.findViewById(R.id.at_date)) // .getText().toString()); } }); TextView atDate = (TextView) rootView.findViewById(R.id.at_date); atDate.setText(getCurrentDate()); Button backBtn = (Button) rootView.findViewById(R.id.date_back); backBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dateBackAndForth(true); } }); Button forthBtn = (Button) rootView.findViewById(R.id.date_next); forthBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dateBackAndForth(false); } }); updateTitleAndType(); data_line = updateTrafficOnDate(getCurrentDate(), firstGrpType); data_bar = updateTrafficOnDate(getCurrentDate(), secondGrpType); redrawCharts(); LinearLayout layout_light = (LinearLayout) rootView.findViewById(R.id.light_graph); LinearLayout layout_motion = (LinearLayout) rootView.findViewById(R.id.motion_graph); layout_light.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { openBig(); } }); layout_motion.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { openBig(); } }); }
From source file:com.daiv.android.twitter.settings.SettingsActivityOld.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); overridePendingTransition(R.anim.slide_in_left, R.anim.activity_zoom_exit); AppSettings.invalidate();/*from w w w . j a v a 2s. c om*/ setUpTheme(); setContentView(R.layout.settings_main); DrawerArrayAdapter.current = 0; linkItems = new String[] { getResources().getString(R.string.get_help_settings), getResources().getString(R.string.other_apps), getResources().getString(R.string.whats_new), getResources().getString(R.string.rate_it) }; settingsItems = new String[] { getResources().getString(R.string.ui_settings), getResources().getString(R.string.timelines_settings), getResources().getString(R.string.sync_settings), getResources().getString(R.string.notification_settings), getResources().getString(R.string.browser_settings), getResources().getString(R.string.advanced_settings), getResources().getString(R.string.memory_manage) }; sharedPrefs = getSharedPreferences("com.daiv.android.twitter_world_preferences", Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE); if (sharedPrefs.getBoolean("version_1.20_1", true)) { // necessary because i didnt start out by using sets boolean led = sharedPrefs.getBoolean("led", true); boolean sound = sharedPrefs.getBoolean("sound", true); boolean vibrate = sharedPrefs.getBoolean("vibrate", true); boolean wakeScreen = sharedPrefs.getBoolean("wake", true); boolean timelineNot = sharedPrefs.getBoolean("timeline_notifications", true); boolean mentionsNot = sharedPrefs.getBoolean("mentions_notifications", true); boolean dmsNot = sharedPrefs.getBoolean("direct_message_notifications", true); boolean favoritesNot = sharedPrefs.getBoolean("favorite_notifications", true); boolean retweetNot = sharedPrefs.getBoolean("retweet_notifications", true); boolean followersNot = sharedPrefs.getBoolean("follower_notifications", true); Set<String> alert = sharedPrefs.getStringSet("alert_types", new HashSet<String>()); alert.clear(); if (vibrate) { alert.add("1"); } if (led) { alert.add("2"); } if (wakeScreen) { alert.add("3"); } if (sound) { alert.add("4"); } sharedPrefs.edit().putStringSet("alert_types", alert).commit(); Set<String> timeline = sharedPrefs.getStringSet("timeline_set", new HashSet<String>()); timeline.clear(); if (timelineNot) { timeline.add("1"); } if (mentionsNot) { timeline.add("2"); } if (dmsNot) { timeline.add("3"); } sharedPrefs.edit().putStringSet("timeline_set", timeline).commit(); Set<String> interactions = sharedPrefs.getStringSet("interactions_set", new HashSet<String>()); interactions.clear(); if (favoritesNot) { interactions.add("1"); } if (retweetNot) { interactions.add("2"); } if (followersNot) { interactions.add("3"); } sharedPrefs.edit().putStringSet("interactions_set", interactions).commit(); sharedPrefs.edit().putBoolean("version_1.20_1", false).commit(); recreate(); } mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager(), this, otherList); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START); otherList = (ListView) findViewById(R.id.other_list); settingsList = (ListView) findViewById(R.id.settings_list); mDrawer = (LinearLayout) findViewById(R.id.drawer); // Set the adapter for the list view otherList.setAdapter(new DrawerArrayAdapter(this, new ArrayList<String>(Arrays.asList(linkItems)))); settingsList.setAdapter(new DrawerArrayAdapter(this, new ArrayList<String>(Arrays.asList(settingsItems)))); // Set the list's click listener settingsList.setOnItemClickListener( new SettingsDrawerClickListener(this, mDrawerLayout, settingsList, mViewPager, mDrawer)); otherList.setOnItemClickListener( new SettingsLinkDrawerClickListener(this, mDrawerLayout, otherList, mViewPager, mDrawer)); findViewById(R.id.settingsLinks).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { switchToSettingsList(true); settingsLinksActive = true; findViewById(R.id.settingsSelector).setVisibility(View.VISIBLE); findViewById(R.id.otherSelector).setVisibility(View.INVISIBLE); } }); findViewById(R.id.otherLinks).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { switchToSettingsList(false); settingsLinksActive = false; findViewById(R.id.settingsSelector).setVisibility(View.INVISIBLE); findViewById(R.id.otherSelector).setVisibility(View.VISIBLE); } }); if (settingsLinksActive) { settingsList.setVisibility(View.VISIBLE); otherList.setVisibility(View.GONE); findViewById(R.id.settingsSelector).setVisibility(View.VISIBLE); findViewById(R.id.otherSelector).setVisibility(View.INVISIBLE); } else { settingsList.setVisibility(View.GONE); otherList.setVisibility(View.VISIBLE); findViewById(R.id.settingsSelector).setVisibility(View.INVISIBLE); findViewById(R.id.otherSelector).setVisibility(View.VISIBLE); } TypedArray a = getTheme().obtainStyledAttributes(new int[] { R.attr.drawerIcon }); int resource = a.getResourceId(0, 0); a.recycle(); mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ mDrawerLayout, /* DrawerLayout object */ resource, /* nav drawer icon to replace 'Up' caret */ R.string.app_name, /* "open drawer" description */ R.string.app_name /* "close drawer" description */ ); mDrawerLayout.setDrawerListener(mDrawerToggle); getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); userKnows = sharedPrefs.getBoolean("user_knows_navigation_drawer", false); mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { public void onPageScrollStateChanged(int state) { } public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } public void onPageSelected(int position) { DrawerArrayAdapter.current = position; otherList.invalidateViews(); settingsList.invalidateViews(); } }); if (!userKnows) { mDrawerLayout.openDrawer(mDrawer); } HoloTextView createdBy = (HoloTextView) findViewById(R.id.created_by); HoloTextView versionNumber = (HoloTextView) findViewById(R.id.version_number); try { String versionName = getPackageManager().getPackageInfo(getPackageName(), 0).versionName; String text = getResources().getString(R.string.created_by) + " daiv"; String text2 = getResources().getString(R.string.version) + " " + versionName; createdBy.setText(text); versionNumber.setText(text2); } catch (Exception e) { String text = getResources().getString(R.string.created_by) + " daiv"; String text2 = getResources().getString(R.string.version) + " 0.00"; createdBy.setText(text); versionNumber.setText(text2); } LinearLayout description = (LinearLayout) findViewById(R.id.created_by_layout); description.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/developer?id=daiv+Apps"))); } }); mDrawerLayout.openDrawer(Gravity.START); }
From source file:com.klinker.android.twitter.settings.SettingsActivityOld.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); overridePendingTransition(R.anim.slide_in_left, R.anim.activity_zoom_exit); AppSettings.invalidate();/* w w w. j a v a 2 s . c om*/ setUpTheme(); setContentView(R.layout.settings_main); DrawerArrayAdapter.current = 0; linkItems = new String[] { getResources().getString(R.string.get_help_settings), getResources().getString(R.string.other_apps), getResources().getString(R.string.whats_new), getResources().getString(R.string.rate_it) }; settingsItems = new String[] { getResources().getString(R.string.ui_settings), getResources().getString(R.string.timelines_settings), getResources().getString(R.string.sync_settings), getResources().getString(R.string.notification_settings), getResources().getString(R.string.browser_settings), getResources().getString(R.string.advanced_settings), getResources().getString(R.string.memory_manage) }; sharedPrefs = getSharedPreferences("com.klinker.android.twitter_world_preferences", Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE); if (sharedPrefs.getBoolean("version_1.20_1", true)) { // necessary because i didnt start out by using sets boolean led = sharedPrefs.getBoolean("led", true); boolean sound = sharedPrefs.getBoolean("sound", true); boolean vibrate = sharedPrefs.getBoolean("vibrate", true); boolean wakeScreen = sharedPrefs.getBoolean("wake", true); boolean timelineNot = sharedPrefs.getBoolean("timeline_notifications", true); boolean mentionsNot = sharedPrefs.getBoolean("mentions_notifications", true); boolean dmsNot = sharedPrefs.getBoolean("direct_message_notifications", true); boolean favoritesNot = sharedPrefs.getBoolean("favorite_notifications", true); boolean retweetNot = sharedPrefs.getBoolean("retweet_notifications", true); boolean followersNot = sharedPrefs.getBoolean("follower_notifications", true); Set<String> alert = sharedPrefs.getStringSet("alert_types", new HashSet<String>()); alert.clear(); if (vibrate) { alert.add("1"); } if (led) { alert.add("2"); } if (wakeScreen) { alert.add("3"); } if (sound) { alert.add("4"); } sharedPrefs.edit().putStringSet("alert_types", alert).commit(); Set<String> timeline = sharedPrefs.getStringSet("timeline_set", new HashSet<String>()); timeline.clear(); if (timelineNot) { timeline.add("1"); } if (mentionsNot) { timeline.add("2"); } if (dmsNot) { timeline.add("3"); } sharedPrefs.edit().putStringSet("timeline_set", timeline).commit(); Set<String> interactions = sharedPrefs.getStringSet("interactions_set", new HashSet<String>()); interactions.clear(); if (favoritesNot) { interactions.add("1"); } if (retweetNot) { interactions.add("2"); } if (followersNot) { interactions.add("3"); } sharedPrefs.edit().putStringSet("interactions_set", interactions).commit(); sharedPrefs.edit().putBoolean("version_1.20_1", false).commit(); recreate(); } mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager(), this, otherList); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START); otherList = (ListView) findViewById(R.id.other_list); settingsList = (ListView) findViewById(R.id.settings_list); mDrawer = (LinearLayout) findViewById(R.id.drawer); // Set the adapter for the list view otherList.setAdapter(new DrawerArrayAdapter(this, new ArrayList<String>(Arrays.asList(linkItems)))); settingsList.setAdapter(new DrawerArrayAdapter(this, new ArrayList<String>(Arrays.asList(settingsItems)))); // Set the list's click listener settingsList.setOnItemClickListener( new SettingsDrawerClickListener(this, mDrawerLayout, settingsList, mViewPager, mDrawer)); otherList.setOnItemClickListener( new SettingsLinkDrawerClickListener(this, mDrawerLayout, otherList, mViewPager, mDrawer)); findViewById(R.id.settingsLinks).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { switchToSettingsList(true); settingsLinksActive = true; findViewById(R.id.settingsSelector).setVisibility(View.VISIBLE); findViewById(R.id.otherSelector).setVisibility(View.INVISIBLE); } }); findViewById(R.id.otherLinks).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { switchToSettingsList(false); settingsLinksActive = false; findViewById(R.id.settingsSelector).setVisibility(View.INVISIBLE); findViewById(R.id.otherSelector).setVisibility(View.VISIBLE); } }); if (settingsLinksActive) { settingsList.setVisibility(View.VISIBLE); otherList.setVisibility(View.GONE); findViewById(R.id.settingsSelector).setVisibility(View.VISIBLE); findViewById(R.id.otherSelector).setVisibility(View.INVISIBLE); } else { settingsList.setVisibility(View.GONE); otherList.setVisibility(View.VISIBLE); findViewById(R.id.settingsSelector).setVisibility(View.INVISIBLE); findViewById(R.id.otherSelector).setVisibility(View.VISIBLE); } TypedArray a = getTheme().obtainStyledAttributes(new int[] { R.attr.drawerIcon }); int resource = a.getResourceId(0, 0); a.recycle(); mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ mDrawerLayout, /* DrawerLayout object */ resource, /* nav drawer icon to replace 'Up' caret */ R.string.app_name, /* "open drawer" description */ R.string.app_name /* "close drawer" description */ ); mDrawerLayout.setDrawerListener(mDrawerToggle); getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); userKnows = sharedPrefs.getBoolean("user_knows_navigation_drawer", false); mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { public void onPageScrollStateChanged(int state) { } public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } public void onPageSelected(int position) { DrawerArrayAdapter.current = position; otherList.invalidateViews(); settingsList.invalidateViews(); } }); if (!userKnows) { mDrawerLayout.openDrawer(mDrawer); } HoloTextView createdBy = (HoloTextView) findViewById(R.id.created_by); HoloTextView versionNumber = (HoloTextView) findViewById(R.id.version_number); try { String versionName = getPackageManager().getPackageInfo(getPackageName(), 0).versionName; String text = getResources().getString(R.string.created_by) + " Luke Klinker"; String text2 = getResources().getString(R.string.version) + " " + versionName; createdBy.setText(text); versionNumber.setText(text2); } catch (Exception e) { String text = getResources().getString(R.string.created_by) + " Luke Klinker"; String text2 = getResources().getString(R.string.version) + " 0.00"; createdBy.setText(text); versionNumber.setText(text2); } LinearLayout description = (LinearLayout) findViewById(R.id.created_by_layout); description.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/developer?id=Klinker+Apps"))); } }); mDrawerLayout.openDrawer(Gravity.START); }
From source file:org.ambient.control.config.EditConfigFragment.java
private void addFieldToView(LayoutInflater inflater, final Object config, LinearLayout content, final Field field) throws IllegalAccessException, ClassNotFoundException, java.lang.InstantiationException { LinearLayout fieldView = (LinearLayout) inflater.inflate(R.layout.layout_editconfig_entry, null); content.addView(fieldView);//from ww w . j a v a2s . co m TextView title = (TextView) fieldView.findViewById(R.id.textViewTitleOfMap); title.setText(field.getName()); if (field.getAnnotation(Presentation.class) != null && field.getAnnotation(Presentation.class).name().isEmpty() == false) { title.setText((field.getAnnotation(Presentation.class).name())); final String description = (field.getAnnotation(Presentation.class)).description(); if (description.isEmpty() == false) { // add a help button with the description of this field to title fieldView.findViewById(R.id.imageViewEditEntryHelp).setVisibility(View.VISIBLE); LinearLayout header = (LinearLayout) fieldView.findViewById(R.id.linearLayoutConfigEntryHeader); header.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle("Hilfe").setMessage(description).setPositiveButton("OK", null).create() .show(); } }); } } // draw concrete view elements for each supported field type LinearLayout contentArea = (LinearLayout) fieldView.findViewById(R.id.linearLayoutConfigEntryContent); TypeDef typedef = field.getAnnotation(TypeDef.class); if (typedef.fieldType().equals(FieldType.EXPRESSION)) { new ExpressionField(roomConfig, config, field, this, contentArea).createView(); } if (typedef.fieldType().equals(FieldType.BEAN)) { new BeanField(roomConfig, config, field, this, contentArea).createView(selectedRoom); } if (typedef.fieldType().equals(FieldType.BEAN_SELECTION)) { new BeanSelectionField(roomConfig, config, field, this, contentArea).createView(); } if (typedef.fieldType().equals(FieldType.STRING)) { new StringField(roomConfig, config, field, this, contentArea).createView(); } if (typedef.fieldType().equals(FieldType.BOOLEAN)) { new BooleanField(roomConfig, config, field, this, contentArea).createView(); } if (typedef.fieldType().equals(FieldType.COLOR)) { new ColorField(roomConfig, config, field, this, contentArea).createView(); } if (typedef.fieldType().equals(FieldType.NUMERIC)) { new NumericField(roomConfig, config, field, this, contentArea).createView(typedef); } if (typedef.fieldType().equals(FieldType.MAP)) { new MapField(roomConfig, config, field, this, contentArea).createView(selectedRoom); } if (typedef.fieldType().equals(FieldType.SELECTION_LIST)) { new SelectionListField(roomConfig, config, field, this, contentArea).createView(); } if (typedef.fieldType().equals(FieldType.SIMPLE_LIST)) { new SimpleListField(roomConfig, config, field, this, contentArea).createView(selectedRoom); } }
From source file:com.eugene.fithealthmaingit.UI.ManualEntrySaveMealFragment.java
private void updateItems() { mToolbar.setNavigationIcon(R.mipmap.ic_arrow_back); mToolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override/*from ww w.j a v a 2 s .c o m*/ public void onClick(View v) { Intent intent = new Intent(getActivity(), ChooseAddMealActivity.class); intent.putExtra(Globals.MEAL_TYPE, mealType); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); } }); mToolbar.inflateMenu(R.menu.menu_user_info); mToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { if (menuItem.getItemId() == R.id.action_save) saveMeal(); return false; } }); mServingSizeUpdated.setText("1"); LinearLayout changeServing = (LinearLayout) v.findViewById(R.id.changeServing); changeServing.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); alert.setTitle("Update Serving Size: "); alert.setMessage("Servings Consumed"); final EditText input = new EditText(getActivity()); input.setText(mServingg.getText().toString()); input.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); input.selectAll(); input.setGravity(Gravity.CENTER_HORIZONTAL); alert.setView(input, 64, 0, 64, 0); alert.setPositiveButton("Update", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { double values = Double.valueOf(input.getText().toString()); mServingg.setText(df.format(values)); mServingSizeUpdated.setText(df.format(values)); mCalUpdate.setText(dfW.format(Double.valueOf(mCalories) * values)); mCalorieProgress = Double.valueOf(mCalories) * values; mFattieUpdate.setText(df.format(Double.valueOf(mFat) * values)); mFatProgress = Double.valueOf(mFat) * values; mSaturatedFatUpdate.setText(df.format(Double.valueOf(mSaturatedFat) * values)); mCholesterolUpdate.setText(df.format(Double.valueOf(mCholesterol) * values)); mSodiumUpdate.setText(df.format(Double.valueOf(mSodium) * values)); mCarbUpdate.setText(df.format(Double.valueOf(mCarbohydrates) * values)); mCarbProgress = Double.valueOf(mCarbohydrates) * values; mFiberUpdate.setText(df.format(Double.valueOf(mFiber) * values)); mSugarUpdate.setText(df.format(Double.valueOf(mSugar) * values)); mProUpdate.setText(df.format(Double.valueOf(mProtein) * values)); mProteinProgress = Double.valueOf(mProtein) * values; mVitAUpdate.setText(df.format(Double.valueOf(mVitA) * values)); mVitCUpdate.setText(df.format(Double.valueOf(mVitC) * values)); mCalciumUpdate.setText(df.format(Double.valueOf(mCalcium) * values)); mIronUpdate.setText(df.format(Double.valueOf(mIron) * values)); progressBars(); ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(input.getWindowToken(), 0); } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(input.getWindowToken(), 0); } }); alert.setCancelable(false); alert.show(); ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE)) .toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_NOT_ALWAYS); } }); }