@Override public void onAttach(Activity activity) { // TODO Auto-generated method stub super.onAttach(activity); Log.d(TAG, "onAttach"); super.onAttach(activity); if (activity instanceof ImportFileListener) { listener = (ImportFileListener) activity; } else { throw new UnsupportedOperationException( activity.toString() + " must implement ImportFileListener"); } }
@Override public void onActivityCreated(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onActivityCreated(savedInstanceState); adapter = new SimpleCursorAdapter( getActivity(), R.layout.main_list_item, null, new String[] {DataProvider.COL_NAME, DataProvider.COL_COUNT}, new int[] {R.id.text1, R.id.text2}, 0); adapter.setViewBinder( new SimpleCursorAdapter.ViewBinder() { @Override public boolean setViewValue(View view, Cursor cursor, int columnIndex) { int id = view.getId(); if (id == R.id.text2) { int count = cursor.getInt(columnIndex); if (count > 0) { ((TextView) view) .setText(String.format("%d new message%s", count, count == 1 ? "" : "s")); } return true; } return false; } }); setListAdapter(adapter); getLoaderManager().initLoader(0, null, ChatsFragment.this); }
@Override public void onPause() { super.onPause(); // In the case onPause() is called during a fling the image loader is un-paused to let any // remaining background work complete. mImageLoader.setPauseWork(false); }
@Override public void onAttach(Context context) { super.onAttach(context); context .getContentResolver() .registerContentObserver(EventsContract.CONTENT_URI, true, mEventsObserver); }
@Override public void onAttach(Activity activity) { super.onAttach(activity); if (activity instanceof FragmentTestStarter) { this.activity = (FragmentTestStarter) activity; } }
@Override public void onDetach() { super.onDetach(); // Reset the active callbacks interface to the dummy implementation. mCallbacks = sDummyCallbacks; }
@Override public void onListItemClick(ListView listView, View view, int position, long id) { super.onListItemClick(listView, view, position, id); // 发送列表项点击事件,直接使用getItem,这里是DummyItem类型 Log.d(MainActivity.TAG, "Clicked item:" + position); EventBus.getDefault().post(getListView().getItemAtPosition(position)); }
@Override public void onAttach(Activity activity) { super.onAttach(activity); mImageLoader = ((BaseActivity) getActivity()).getImageLoader(); mOptions = ((BaseActivity) getActivity()).getOptions(); }
@Override public void onStart() { this.registerForContextMenu(getListView()); getListView().setItemsCanFocus(true); getListView().setLongClickable(true); getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); getListView() .setOnItemLongClickListener( new OnItemLongClickListener() { @Override public boolean onItemLongClick( AdapterView<?> arg0, View view, int position, long id) { if (!inContextMode) { deleteIndex = position; getActivity().openContextMenu(getListView()); return true; } return false; } }); setAddButtonListener(getActivity()); adapter.notifyDataSetChanged(); super.onStart(); }
/** Creates the context menu that will be available for the items in the players list */ @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { MenuInflater inflater = new MenuInflater(getActivity()); inflater.inflate(R.menu.deelete_ctx_menu, menu); inflater.inflate(R.menu.edit_ctx_menu, menu); super.onCreateContextMenu(menu, v, menuInfo); }
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); ImageLoaderConfiguration conf = new ImageLoaderConfiguration.Builder(getActivity()).build(); ImageLoader imageLoader = ImageLoader.getInstance(); imageLoader.init(conf); adapter = new FriendsArrayAdapter(getActivity(), R.layout.row_friends, imageLoader, this); setListAdapter(adapter); realm = Realm.getInstance(getActivity()); RealmResults<Friend> results = realm.allObjects(Friend.class); // TODO: Run async if (results.size() > 0) { if (!compact) { getListView().setVisibility(View.VISIBLE); progressBar.setVisibility(View.GONE); } adapter.update(results); } refreshFriends(); // TODO: Timeout on the refresh rate? }
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); getListView() .setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick( AdapterView<?> adapterView, View view, int position, long id) { String selectedPackageName = mAdapter.getItemPackageName(position); // edit app settings Intent intent = new Intent(getActivity(), AppSettingsActivity.class); intent.setData(KeychainContract.ApiApps.buildByPackageNameUri(selectedPackageName)); startActivity(intent); } }); // Give some text to display if there is no data. In a real // application this would come from a resource. setEmptyText(getString(R.string.api_no_apps)); // We have a menu item to show in action bar. setHasOptionsMenu(true); // Create an empty adapter we will use to display the loaded data. mAdapter = new RegisteredAppsAdapter(getActivity(), null, 0); setListAdapter(mAdapter); // Prepare the loader. Either re-connect with an existing one, // or start a new one. getLoaderManager().initLoader(0, null, this); }
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); SwipeDismissList swipeDismissList = new SwipeDismissList( getListView(), getLLQueue().mSwipeCallback, SwipeDismissList.UndoMode.SINGLE_UNDO); }
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); // Inflate the menu; this adds items to the action bar if it is present. inflater.inflate(R.menu.main, menu); }
@Override public void onCreate(Bundle saveInstanceState) { super.onCreate(saveInstanceState); setHasOptionsMenu(true); getActivity().setTitle(R.string.crimes_title); /* * 调用 CrimeLab的静态方法get * 在get()内部创建CrimeLab对象,(单例)。同时返回对象 * 在CrimeListFragment中使用此对象: mCrimes 进行工作 */ mCrimes = CrimeLab.get(getActivity()).getCrimes(); // --显示 圆圈圈 的 运行图标,资源布局使用系统却省的: // android.R.layout.simple_list_item_1 // ArrayAdapter<Crime>adapter = // new ArrayAdapter<Crime>(getActivity(), // android.R.layout.simple_list_item_1, // mCrimes); // 创建 控制器 对象 Adapter ----- 用于控制:模型与视图之间的交换控制 /* * (1)创建必要的视图对象 * (2)用模型层数据填充视图对象 * (3)将准备好的视图对象返回给ListView */ CrimeAdapter adapter = new CrimeAdapter(mCrimes); setListAdapter(adapter); }
@Override public void onDetach() { // TODO Auto-generated method stub Log.i("OnDetach", "leaving this fragment"); mRequestQueue.cancelAll(REQUEST_TAG); super.onDetach(); }
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); inflater.inflate(R.menu.start, menu); mMenu = menu; };
@Override public void onCreate(@Nullable Bundle savedInstanceState) { Log.v(LOG_TAG, "onCreate(): "); super.onCreate(savedInstanceState); MyNetworkStatus.getNetworkConnection(getActivity(), TAG); context = getContext(); mFragmentManager = getActivity().getSupportFragmentManager(); MyNetworkStatus.getNetworkConnection(context, TAG); mSharedPreferences = getActivity().getPreferences(Context.MODE_PRIVATE); bookMarkHelper = new BookMarkHelper(getActivity()); builder = new AlertDialog.Builder(getActivity()); ((MainActivity) getActivity()).hideSearchMenuItem(); mSiteItemList = bookMarkHelper.getBookMarks(); if (mSiteItemList.size() < 0) { builder .setTitle("BookMark") .setMessage("Data is empty, please choose!") .setPositiveButton( "OK", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { mFragmentManager .beginTransaction() .replace(R.id.container, new SiteListFragment()) .commit(); } }) .show(); return; } preferences = getActivity().getSharedPreferences("config", Context.MODE_PRIVATE); }
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE); // 开启工作线程加载列表 new WorkerThread().start(); }
@Override public void onStart() { super.onStart(); /** Setting the multiselect choice mode for the listview */ getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRetainInstance(true); IntentFilter filter = new IntentFilter(HotelIntentService.ACAO_SINCRONIZAR); LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mServiceReceiver, filter); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setListAdapter( new ArrayAdapter<DummyContent.DummyItem>( getActivity(), R.layout.simple_list_item_activated_1, R.id.text1, DummyContent.ITEMS)); }
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); int[] ids = getArguments().getIntArray(EXTRA_CARDS_FILTERED); adapter = new CardDescriptionAdapter(getActivity(), ids); setListAdapter(adapter); }
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); if (savedInstanceState != null && savedInstanceState.containsKey(STATE_ACTIVATED_POSITION)) { setActivatedPosition(savedInstanceState.getInt(STATE_ACTIVATED_POSITION)); } }
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Populate list with our static array of titles. setListAdapter( new ArrayAdapter<String>( getActivity(), R.layout.simple_list_item_checkable_1, android.R.id.text1, Shakespeare.TITLES)); // Check to see if we have a frame in which to embed the details // fragment directly in the containing UI. View detailsFrame = getActivity().findViewById(R.id.details); mDualPane = detailsFrame != null && detailsFrame.getVisibility() == View.VISIBLE; if (savedInstanceState != null) { // Restore last state for checked position. mCurCheckPosition = savedInstanceState.getInt("curChoice", 0); } if (mDualPane) { // In dual-pane mode, the list view highlights the selected item. getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE); // Make sure our UI is in the correct state. showDetails(mCurCheckPosition); } }
@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); if (mActivatedPosition != ListView.INVALID_POSITION) { outState.putInt(STATE_ACTIVATED_POSITION, mActivatedPosition); } }
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Set up ListView, assign adapter and set some listeners. The adapter was previously created in // onCreate(). setListAdapter(mAdapter); getListView().setOnItemClickListener(this); getListView() .setOnScrollListener( new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView absListView, int scrollState) { // Pause image loader to ensure smoother scrolling when flinging if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_FLING) { mImageLoader.setPauseWork(true); } else { mImageLoader.setPauseWork(false); } } @Override public void onScroll(AbsListView absListView, int i, int i1, int i2) {} }); // If there's a previously selected search item from a saved state then don't bother // initializing the loader // as it will be restarted later when the query is populated into the action bar search view. if (mPreviouslySelectedSearchItem == 0) { // Initialize the loader, and create a loader identified by ContactsQuery.QUERY_ID getLoaderManager().initLoader(ContactsQuery.QUERY_ID, null, this); } }
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); fm = getActivity().getSupportFragmentManager(); mTransactions = TransactionData.get(getActivity()).getTransactions(); adapter = new TransactionAdapter(mTransactions); setListAdapter(adapter); } // onCreate
@Override public void onStart() { super.onStart(); Intent intent = new Intent(getActivity(), DataProvider.class); getActivity().bindService(intent, mConnection, Context.BIND_AUTO_CREATE); Log.i("HabrQA", "Service started"); };
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); listItens = Arrays.asList( new ItemTO("Primeiro"), new ItemTO("Segundo"), new ItemTO("Terceiro"), new ItemTO("Quarto"), new ItemTO("Quinto"), new ItemTO("Sexto"), new ItemTO("Primeiro"), new ItemTO("Segundo"), new ItemTO("Terceiro"), new ItemTO("Quarto"), new ItemTO("Quinto"), new ItemTO("Sexto"), new ItemTO("Primeiro"), new ItemTO("Segundo"), new ItemTO("Terceiro"), new ItemTO("Quarto"), new ItemTO("Quinto"), new ItemTO("Sexto")); myListAdapter = new MyListAdapter(); setListAdapter(myListAdapter); }