List of usage examples for android.widget ListView setAdapter
@Override public void setAdapter(ListAdapter adapter)
From source file:com.cj.arcard.ui.RobotsActivity.java
@Override @TargetApi(14)/*ww w . j ava 2 s . com*/ protected void onCreate(Bundle arg0) { super.onCreate(arg0); setContentView(R.layout.em_fragment_robots); inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); ListView mListView = (ListView) findViewById(R.id.list); swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_layout); if (android.os.Build.VERSION.SDK_INT >= 14) { swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light); } progressBar = findViewById(R.id.progress_bar); swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh() { getRobotNamesFromServer(); } }); Map<String, RobotUser> robotMap = DemoHelper.getInstance().getRobotList(); if (robotMap != null) { robotList.addAll(robotMap.values()); } else { progressBar.setVisibility(View.VISIBLE); getRobotNamesFromServer(); } adapter = new RobotAdapter(this, 1, robotList); mListView.setAdapter(adapter); mListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { RobotUser user = (RobotUser) parent.getItemAtPosition(position); Intent intent = new Intent(); intent.setClass(RobotsActivity.this, ChatActivity.class); intent.putExtra("userId", user.getUsername()); startActivity(intent); } }); mListView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (getWindow() .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { if (getCurrentFocus() != null) inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } return false; } }); }
From source file:cn.ucai.wechat.ui.RobotsActivity.java
@Override @TargetApi(14)// ww w. j ava2 s.c om protected void onCreate(Bundle arg0) { super.onCreate(arg0); setContentView(R.layout.em_fragment_robots); inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); ListView mListView = (ListView) findViewById(R.id.list); swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_layout); if (android.os.Build.VERSION.SDK_INT >= 14) { swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light); } progressBar = findViewById(R.id.progress_bar); swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh() { getRobotNamesFromServer(); } }); Map<String, RobotUser> robotMap = WeChatHelper.getInstance().getRobotList(); if (robotMap != null) { robotList.addAll(robotMap.values()); } else { progressBar.setVisibility(View.VISIBLE); getRobotNamesFromServer(); } adapter = new RobotAdapter(this, 1, robotList); mListView.setAdapter(adapter); mListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { RobotUser user = (RobotUser) parent.getItemAtPosition(position); Intent intent = new Intent(); intent.setClass(RobotsActivity.this, ChatActivity.class); intent.putExtra("userId", user.getUsername()); startActivity(intent); } }); mListView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (getWindow() .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { if (getCurrentFocus() != null) inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } return false; } }); }
From source file:cn.wyl.superwechat.ui.RobotsActivity.java
@Override protected void onCreate(Bundle arg0) { super.onCreate(arg0); setContentView(R.layout.em_fragment_robots); inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); ListView mListView = (ListView) findViewById(R.id.list); swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_layout); if (android.os.Build.VERSION.SDK_INT >= 14) { swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light); }//from ww w. j a v a2s. co m progressBar = findViewById(R.id.progress_bar); swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh() { getRobotNamesFromServer(); } }); Map<String, RobotUser> robotMap = SuperWeChatHelper.getInstance().getRobotList(); if (robotMap != null) { robotList.addAll(robotMap.values()); } else { progressBar.setVisibility(View.VISIBLE); getRobotNamesFromServer(); } adapter = new RobotAdapter(this, 1, robotList); mListView.setAdapter(adapter); mListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { RobotUser user = (RobotUser) parent.getItemAtPosition(position); Intent intent = new Intent(); intent.setClass(RobotsActivity.this, ChatActivity.class); intent.putExtra("userId", user.getUsername()); startActivity(intent); } }); mListView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (getWindow() .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { if (getCurrentFocus() != null) inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } return false; } }); }
From source file:cn.moon.superwechat.ui.RobotsActivity.java
@Override @TargetApi(14)// w w w .j ava2 s . c om protected void onCreate(Bundle arg0) { super.onCreate(arg0); setContentView(R.layout.em_fragment_robots); inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); ListView mListView = (ListView) findViewById(R.id.list); swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_layout); if (android.os.Build.VERSION.SDK_INT >= 14) { swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light); } progressBar = findViewById(R.id.progress_bar); swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh() { getRobotNamesFromServer(); } }); Map<String, RobotUser> robotMap = SuperWeChatHelper.getInstance().getRobotList(); if (robotMap != null) { robotList.addAll(robotMap.values()); } else { progressBar.setVisibility(View.VISIBLE); getRobotNamesFromServer(); } adapter = new RobotAdapter(this, 1, robotList); mListView.setAdapter(adapter); mListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { RobotUser user = (RobotUser) parent.getItemAtPosition(position); Intent intent = new Intent(); intent.setClass(RobotsActivity.this, ChatActivity.class); intent.putExtra("userId", user.getUsername()); startActivity(intent); } }); mListView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (getWindow() .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { if (getCurrentFocus() != null) inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } return false; } }); }
From source file:ca.ualberta.cmput301w14t08.geochan.fragments.CustomLocationFragment.java
/** * Setups up the Location Log to display previous locations, connects the UI * buttons, starts listening for location updates and finally calls setup * map. Gets the proper fragment manager and sets it to fragManager. * //from w ww. java2 s .co m */ public void onStart() { super.onStart(); GeoLocationLog log = GeoLocationLog.generateInstance(getActivity()); ArrayList<GeoLocation> logArray = log.getLogEntries(); FavouritesFragment favFrag = (FavouritesFragment) getFragmentManager().findFragmentByTag("favouritesFrag"); if (favFrag != null) { fragManager = getChildFragmentManager(); } else { fragManager = getFragmentManager(); } ListView lv = (ListView) getView().findViewById(R.id.custom_location_list_view); locationListenerService = new LocationListenerService(getActivity()); locationListenerService.startListening(); markers = new ArrayList<Marker>(); lv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // clicks a previous location item in the list GeoLocation logEntry = (GeoLocation) parent.getItemAtPosition(position); setBundleArguments(logEntry, "PREVIOUS_LOCATION"); fragManager.popBackStackImmediate(); } }); CustomLocationAdapter customLocationAdapter = new CustomLocationAdapter(getActivity(), logArray); lv.setAdapter(customLocationAdapter); setupMap(getMapEventsReceiver()); mapData.refreshMap(); }
From source file:com.manning.androidhacks.hack040.TestListActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.list);//from www. j av a2 s. c om ListView list = (ListView) findViewById(R.id.list); int size = (int) getResources().getDimension(R.dimen.list_image_size); imageWorker = new ImageFetcher(this, size); imageWorker.setImageFadeIn(false); imageWorker.setLoadingImage(R.drawable.ic_launcher); ImageCache.ImageCacheParams cacheParams = new ImageCache.ImageCacheParams(IMAGE_CACHE_DIR); // Allocate a third of the per-app memory limit to the bitmap memory cache. // This value // should be chosen carefully based on a number of factors. Refer to the // corresponding // Android Training class for more discussion: // http://developer.android.com/training/displaying-bitmaps/ // In this case, we aren't using memory for much else other than this // activity and the // ImageDetailActivity so a third lets us keep all our sample image // thumbnails in memory // at once. cacheParams.memCacheSize = 1024 * 1024 * Utils.getMemoryClass(this) / 3; imageWorker.setImageCache(new ImageCache(this, cacheParams)); list.setAdapter(new TestAdapter(this, imageWorker)); }
From source file:cn.ucai.superwechat.ui.RobotsActivity.java
@Override @TargetApi(14)//from w ww. ja va 2 s. c o m protected void onCreate(Bundle arg0) { super.onCreate(arg0); setContentView(R.layout.em_fragment_robots); inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); ListView mListView = (ListView) findViewById(R.id.list); swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_layout); if (android.os.Build.VERSION.SDK_INT >= 14) { swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light); } progressBar = findViewById(R.id.progress_bar); swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh() { getRobotNamesFromServer(); } }); Map<String, RobotUser> robotMap = SuperWeChatDemoHelper.getInstance().getRobotList(); if (robotMap != null) { robotList.addAll(robotMap.values()); } else { progressBar.setVisibility(View.VISIBLE); getRobotNamesFromServer(); } adapter = new RobotAdapter(this, 1, robotList); mListView.setAdapter(adapter); mListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { RobotUser user = (RobotUser) parent.getItemAtPosition(position); Intent intent = new Intent(); intent.setClass(RobotsActivity.this, ChatActivity.class); intent.putExtra("userId", user.getUsername()); startActivity(intent); } }); mListView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (getWindow() .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { if (getCurrentFocus() != null) inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } return false; } }); }
From source file:org.telegram.ui.myLocationSettingsActivity.java
@Override public View createView(LayoutInflater inflater) { if (fragmentView == null) { actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setAllowOverlayTitle(true); actionBar.setTitle("My Places"); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override// w w w .j a v a2 s . c o m public void onItemClick(int id) { if (id == -1) { finishFragment(); } } }); listAdapter = new ListAdapter(getParentActivity()); fragmentView = new FrameLayout(getParentActivity()); FrameLayout frameLayout = (FrameLayout) fragmentView; frameLayout.setBackgroundColor(0xfff0f0f0); ListView listView = new ListView(getParentActivity()); listView.setDivider(null); listView.setDividerHeight(0); listView.setVerticalScrollBarEnabled(false); listView.setDrawSelectorOnTop(true); frameLayout.addView(listView); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; layoutParams.gravity = Gravity.TOP; listView.setLayoutParams(layoutParams); listView.setAdapter(listAdapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) { if (i == homeRow) { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle("Home"); final ViewGroup.LayoutParams lparams = new ViewGroup.LayoutParams(50, 30); final EditText input = new EditText(getParentActivity()); input.setHint("Insert city"); input.setLayoutParams(lparams); builder.setView(input); builder.setPositiveButton("confirm", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (input.getText().toString().trim().length() > 0) { String city = input.getText().toString().trim(); try { Bundle locationHome = new getCoordinates().execute(city).get(); String latHome = locationHome.getString("lat"); String lonHome = locationHome.getString("lon"); SharedPreferences sharedPreferences = ApplicationLoader.applicationContext .getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putString("latHome", latHome); editor.putString("longHome", lonHome); editor.commit(); Log.i(TAG, "fine! " + lonHome); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } } else { Toast.makeText(getParentActivity(), "That is empty :(", Toast.LENGTH_SHORT) .show(); } } }); builder.setNegativeButton("Why?", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Toast.makeText(getParentActivity(), "To website", Toast.LENGTH_SHORT).show(); } }); showAlertDialog(builder); } else if (i == workRow) { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle("Work"); final EditText input = new EditText(getParentActivity()); input.setHint("Insert city"); builder.setView(input); builder.setPositiveButton("confirm", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (input.getText().toString().trim().length() > 0) { String city = input.getText().toString().trim(); try { Bundle locationWork = new getCoordinates().execute(city).get(); String latWork = locationWork.getString("lat"); String lonWork = locationWork.getString("lon"); SharedPreferences sharedPreferences = ApplicationLoader.applicationContext .getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putString("latWork", latWork); editor.putString("longWork", lonWork); editor.commit(); Log.i(TAG, "fine! " + latWork); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } } else { Toast.makeText(getParentActivity(), "That is empty :(", Toast.LENGTH_SHORT) .show(); } } }); builder.setNegativeButton("Why?", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Toast.makeText(getParentActivity(), "To website", Toast.LENGTH_SHORT).show(); } }); showAlertDialog(builder); } else if (i == entertainmentRow) { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle("Entertainment"); final EditText input = new EditText(getParentActivity()); input.setHint("Insert city"); builder.setView(input); builder.setPositiveButton("confirm", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (input.getText().toString().trim().length() > 0) { String city = input.getText().toString().trim(); try { Bundle locationEntertainment = new getCoordinates().execute(city).get(); String latEntertainment = locationEntertainment.getString("lat"); String lonEntertainment = locationEntertainment.getString("lon"); SharedPreferences sharedPreferences = ApplicationLoader.applicationContext .getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putString("latEntertainment", latEntertainment); editor.putString("longEntertainment", lonEntertainment); editor.commit(); Log.i(TAG, "fine! " + latEntertainment); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } } else { Toast.makeText(getParentActivity(), "That is empty :(", Toast.LENGTH_SHORT) .show(); } } }); builder.setNegativeButton("Why?", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Toast.makeText(getParentActivity(), "To website", Toast.LENGTH_SHORT).show(); } }); showAlertDialog(builder); } //TODO find a solution for commuteRow as well!! } }); } else { ViewGroup parent = (ViewGroup) fragmentView.getParent(); if (parent != null) { parent.removeView(fragmentView); } } return fragmentView; }
From source file:com.agateau.equiv.ui.MealItemDetailActivity.java
private void setupTabs() { ListView fullListView = new ListView(this); ListView favoriteListView = new ListView(this); mFullListAdapter = new ProductListAdapter(this, mKernel, mProductStore.getItems()); mFavoritesListAdapter = new ProductListAdapter(this, mKernel, mProductStore.getFavoriteItems()); mProductStore.setOnProductStoreChangedListener(new ProductStore.OnProductStoreChangedListener() { @Override/*from w ww . j a v a 2 s .c om*/ public void onFavoriteChanged() { mFavoritesListAdapter.notifyDataSetChanged(); // Notify mFullListAdapter as well because it must update the state of its checkboxes mFullListAdapter.notifyDataSetChanged(); } @Override public void onItemListChanged() { mFullListAdapter.notifyDataSetChanged(); } }); fullListView.setAdapter(mFullListAdapter); favoriteListView.setAdapter(mFavoritesListAdapter); AdapterView.OnItemClickListener listener = new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Product product = (Product) parent.getAdapter().getItem(position); onSelectProduct(product); } }; fullListView.setOnItemClickListener(listener); favoriteListView.setOnItemClickListener(listener); AdapterView.OnItemLongClickListener longClickListener = new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { Product product = (Product) parent.getItemAtPosition(position); editCustomProduct(product); return true; } }; fullListView.setLongClickable(true); favoriteListView.setLongClickable(true); fullListView.setOnItemLongClickListener(longClickListener); favoriteListView.setOnItemLongClickListener(longClickListener); final ActionBar actionBar = getSupportActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); ViewPager viewPager = (ViewPager) findViewById(R.id.pager); ActionBarViewTabBuilder builder = new ActionBarViewTabBuilder(actionBar, viewPager); builder.addTab(fullListView).setText(R.string.add_meal_item_tab_all); builder.addTab(favoriteListView).setText(R.string.add_meal_item_tab_favorites); }
From source file:com.facebook.samples.booleanog.LogicActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); uiHelper = new UiLifecycleHelper(this, callback); uiHelper.onCreate(savedInstanceState); setContentView(R.layout.main);// www.j a v a 2s. c o m // Views logicButton = (Button) findViewById(R.id.logic_button); friendsButton = (Button) findViewById(R.id.friends_button); settingsButton = (Button) findViewById(R.id.settings_button); contentButton = (Button) findViewById(R.id.content_button); logicGroup = (ViewGroup) findViewById(R.id.logic_group); leftSpinner = (Spinner) findViewById(R.id.left_spinner); rightSpinner = (Spinner) findViewById(R.id.right_spinner); andButton = (Button) findViewById(R.id.and_button); orButton = (Button) findViewById(R.id.or_button); resultText = (TextView) findViewById(R.id.result_text); postResultText = (TextView) findViewById(R.id.post_result_text); friendsGroup = (ViewGroup) findViewById(R.id.friends_group); ListView friendActivityList = (ListView) findViewById(R.id.friend_activity_list); String[] mapColumnNames = { "date", "action" }; int[] mapViewIds = { R.id.friend_action_date, R.id.friend_action_data }; friendActivityAdapter = new SimpleCursorAdapter(this, R.layout.friend_activity_row, createEmptyCursor(), mapColumnNames, mapViewIds); friendActivityList.setAdapter(friendActivityAdapter); friendActivityProgressBar = (ProgressBar) findViewById(R.id.friend_activity_progress_bar); settingsGroup = (ViewGroup) findViewById(R.id.settings_group); contentGroup = (ViewGroup) findViewById(R.id.content_group); contentImage = (ImageView) findViewById(R.id.content_image); contentSpinner = (Spinner) findViewById(R.id.content_spinner); // Fragments FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction transaction = fragmentManager.beginTransaction(); friendPickerFragment = (FriendPickerFragment) fragmentManager.findFragmentById(R.id.friend_picker_fragment); if (friendPickerFragment == null) { Bundle args = new Bundle(); args.putBoolean(FriendPickerFragment.SHOW_TITLE_BAR_BUNDLE_KEY, false); friendPickerFragment = new FriendPickerFragment(args); transaction.add(R.id.friend_picker_fragment, friendPickerFragment); } userSettingsFragment = (UserSettingsFragment) fragmentManager.findFragmentById(R.id.login_fragment); if (userSettingsFragment == null) { userSettingsFragment = new UserSettingsFragment(); transaction.add(R.id.login_fragment, userSettingsFragment); } transaction.commit(); // Spinners ArrayAdapter<CharSequence> truthAdapter = ArrayAdapter.createFromResource(this, R.array.truth_values, android.R.layout.simple_spinner_item); truthAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); leftSpinner.setAdapter(truthAdapter); rightSpinner.setAdapter(truthAdapter); contentSpinner.setAdapter(truthAdapter); leftSpinner.setSelection(0); rightSpinner.setSelection(0); // Navigation for (Button button : Arrays.asList(logicButton, friendsButton, settingsButton, contentButton)) { initializeNavigationButton(button); } // Logic initializeCalculationButton(andButton); initializeCalculationButton(orButton); // Friends friendPickerFragment.setOnErrorListener(new PickerFragment.OnErrorListener() { @Override public void onError(PickerFragment<?> fragment, FacebookException error) { LogicActivity.this.onError(error); } }); friendPickerFragment.setUserId("me"); friendPickerFragment.setMultiSelect(false); friendPickerFragment.setOnSelectionChangedListener(new PickerFragment.OnSelectionChangedListener() { @Override public void onSelectionChanged(PickerFragment<?> fragment) { LogicActivity.this.onFriendSelectionChanged(); } }); friendPickerFragment.setExtraFields(Arrays.asList(INSTALLED)); friendPickerFragment.setFilter(new PickerFragment.GraphObjectFilter<GraphUser>() { @Override public boolean includeItem(GraphUser graphObject) { Boolean installed = graphObject.cast(GraphUserWithInstalled.class).getInstalled(); return (installed != null) && installed.booleanValue(); } }); // Content contentSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { LogicActivity.this.onContentSelectionChanged(); } @Override public void onNothingSelected(AdapterView<?> adapterView) { LogicActivity.this.onContentSelectionChanged(); } }); // Restore saved state Button startButton = logicButton; if (savedInstanceState != null) { leftSpinner.setSelection(savedInstanceState.getInt(SAVE_LEFT_OPERAND_SELECTION)); rightSpinner.setSelection(savedInstanceState.getInt(SAVE_RIGHT_OPERAND_SELECTION)); contentSpinner.setSelection(savedInstanceState.getInt(SAVE_CONTENT_SELECTION)); resultText.setText(savedInstanceState.getString(SAVE_RESULT_TEXT)); postResultText.setText(savedInstanceState.getString(SAVE_POST_RESULT_TEXT)); activeTab = savedInstanceState.getString(SAVE_ACTIVE_TAB); pendingPost = savedInstanceState.getBundle(SAVE_PENDING); friendActionList = savedInstanceState.getParcelableArrayList(SAVE_FRIEND_ACTIONS); if ((friendActionList != null) && (friendActionList.size() > 0)) { updateCursor(friendActionList); } if (getString(R.string.navigate_friends).equals(activeTab)) { startButton = friendsButton; } else if (getString(R.string.navigate_content).equals(activeTab)) { startButton = contentButton; } else if (getString(R.string.navigate_settings).equals(activeTab)) { startButton = settingsButton; } } if (!handleNativeLink()) { onNavigateButtonClick(startButton); } }