private void updateLayout() { setContentView(LAYOUT_ID); mScheduleList = (ListView) findViewById(android.R.id.list); mSchedules = new ScheduleAdapter(this, R.layout.schedule_list_row, mCursor); mScheduleList.setAdapter(mSchedules); mScheduleList.setVerticalScrollBarEnabled(true); mScheduleList.setOnItemClickListener(this); mScheduleList.setOnCreateContextMenuListener(this); getSupportLoaderManager().initLoader(TIME_SCHEDULE_LIST_LOADER, null, this); View addSchedule = findViewById(R.id.add_time_schedule); addSchedule.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { addNewSchedule(); } }); // Make the entire view selected when focused. addSchedule.setOnFocusChangeListener( new View.OnFocusChangeListener() { public void onFocusChange(View v, boolean hasFocus) { v.setSelected(hasFocus); } }); }
@TargetApi(11) @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); playlistName = getIntent().getStringExtra("playlist"); if (null != playlistName && playlistName.length() > 0) { isPlayQueue = false; } MPDApplication app = (MPDApplication) getApplication(); setContentView(R.layout.playlist_editlist_activity); if (isPlayQueue) { this.setTitle(R.string.nowPlaying); } else { this.setTitle(playlistName); } update(); app.oMPDAsyncHelper.addStatusChangeListener(this); ListView trackList = getListView(); trackList.setOnCreateContextMenuListener(this); ((TouchInterceptor) trackList).setDropListener(mDropListener); ((TouchInterceptor) trackList).setRemoveListener(mRemoveListener); trackList.setCacheColorHint(0); Button button = (Button) findViewById(R.id.Remove); button.setOnClickListener(this); getSupportActionBar().setDisplayHomeAsUpEnabled(true); }
BookmarksAdapter(ListView listView, List<Bookmark> bookmarks, boolean currentBook) { myBookmarks = bookmarks; myCurrentBook = currentBook; listView.setAdapter(this); listView.setOnItemClickListener(this); listView.setOnCreateContextMenuListener(this); }
private void setUpListeners() { findViewById(R.id.add) .setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { listView.showContextMenu(); } }); listView.setOnCreateContextMenuListener( new OnCreateContextMenuListener() { @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { if (menu.hasVisibleItems()) { /* If it has items already, then the user did not click on the "Add Criteria" button, but instead long held on a row in the list view, which caused CustomFilterAdapter.onCreateContextMenu to be invoked before this onCreateContextMenu method was invoked. */ return; } int i = 0; for (CustomFilterCriterion item : filterCriteriaProvider.getAll()) { menu.add(CustomFilterActivity.MENU_GROUP_FILTER, i, 0, item.name); i++; } } }); }
private void initListView() { /* Loads the items to the ListView. */ refreshFavListItems(); /* Add Context-Menu listener to the ListView. */ // mFavList.setOnItemLongClickListener(); mFavList.setOnCreateContextMenuListener( new OnCreateContextMenuListener() { @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { // TODO Auto-generated method stub menu.setHeaderTitle("ContextMenu"); menu.add(0, CONTEXTMENU_DELETEITEM, 0, "Delete this favorite!"); } }); /* * mFavList.setOnItemLongClickListener( new * AdapterView.OnItemLongClickListener (){ * * @Override public boolean onItemLongClick(AdapterView<?> av, View v, * int pos, long id) { Log.i("Debug", "Log id "+id+" pos "+pos); return * false; } }); */ }
private void updateLayout() { setContentView(R.layout.alarm_clock); mAlarmsList = (ListView) findViewById(R.id.alarms_list); AlarmTimeAdapter adapter = new AlarmTimeAdapter(this, mCursor); mAlarmsList.setAdapter(adapter); mAlarmsList.setVerticalScrollBarEnabled(true); mAlarmsList.setOnItemClickListener(this); mAlarmsList.setOnCreateContextMenuListener(this); View addAlarm = findViewById(R.id.add_alarm); addAlarm.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { addNewAlarm(); } }); // Make the entire view selected when focused. addAlarm.setOnFocusChangeListener( new View.OnFocusChangeListener() { public void onFocusChange(View v, boolean hasFocus) { v.setSelected(hasFocus); } }); View doneButton = findViewById(R.id.done); if (doneButton != null) { doneButton.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { finish(); } }); } }
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); setHasOptionsMenu(true); ListView lv = getListView(); lv.setOnCreateContextMenuListener(this); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); dao = new NoteDao(this, null, Prefs.getSDCardUse(this)); setContentView(R.layout.notelist_view); setDefaultKeyMode(DEFAULT_KEYS_SHORTCUT); mBibleID = getIntent().getLongExtra("bibleid", new Long(-1)); mVersion = getIntent().getIntExtra("version", -1); mBook = getIntent().getIntExtra("book", -1); mChapter = getIntent().getIntExtra("chapter", -1); mVerse = getIntent().getIntExtra("verse", -1); // 검색조건 if ("Y".equals(getIntent().getStringExtra("SEARCH"))) { searchYN = getIntent().getStringExtra("SEARCH"); searchVersion = getIntent().getIntExtra("version", 0); searchTestment = getIntent().getIntExtra("testment", 0); searchOperator = getIntent().getIntExtra("operator", 0); searchKeyword1 = getIntent().getStringExtra("keyword1"); searchKeyword2 = getIntent().getStringExtra("keyword2"); } toCalendar = Calendar.getInstance(); toCalendar.setFirstDayOfWeek(Calendar.SUNDAY); fromCalendar = Calendar.getInstance(); fromCalendar.setFirstDayOfWeek(Calendar.SUNDAY); fromCalendar.add(Calendar.MONTH, -1); ((EditText) findViewById(R.id.from_date)).setText(Common.fmtDate(fromCalendar)); ((EditText) findViewById(R.id.to_date)).setText(Common.fmtDate(toCalendar)); mListView = (ListView) findViewById(R.id.ContentsListView); mListView.setOnCreateContextMenuListener(this); // mListView.setOnTouchListener(this); mListView.setOnItemClickListener(new listOnItemClickListener()); Spinner chapter_spinner = (Spinner) findViewById(R.id.chapters); chapter_spinner.setOnItemSelectedListener(new ChapterOnItemSelectedListener()); // chapter_spinner.setOnCreateContextMenuListener(this); Spinner spin_books = (Spinner) findViewById(R.id.books); ArrayAdapter<CharSequence> adapter_books = ArrayAdapter.createFromResource( this, R.array.all_testment, android.R.layout.simple_spinner_item); adapter_books.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spin_books.setAdapter(adapter_books); spin_books.setOnItemSelectedListener(new BookOnItemSelectedListener()); spin_books.setSelection(mBook); findViewById(R.id.btn_prev).setOnClickListener(this); findViewById(R.id.btn_next).setOnClickListener(this); findViewById(R.id.from_date).setOnClickListener(this); findViewById(R.id.to_date).setOnClickListener(this); }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_servers, container, false); mListView = (ListView) v.findViewById(R.id.serversListView); mListView.setOnItemClickListener(this); mListView.setOnCreateContextMenuListener(this); v.findViewById(R.id.addServerButton) .setOnClickListener( new OnClickListener() { LayoutInflater inflater = getActivity().getLayoutInflater(); final View dialogLayout = inflater.inflate(R.layout.dialog_add_server, null); @Override public void onClick(View v) { // Remove the previous instance of the dialog from the parent view if (dialogLayout.getParent() != null) { ((ViewGroup) dialogLayout.getParent()).removeView(dialogLayout); } final Spinner format = (Spinner) dialogLayout.findViewById(R.id.format); ArrayAdapter<String> adapter = new ArrayAdapter<String>( getActivity(), android.R.layout.simple_spinner_item, FORMAT_CHOICES); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); format.setAdapter(adapter); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder .setView(dialogLayout) .setTitle(R.string.button_add_server) .setPositiveButton( R.string.save, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { saveNewServer(dialogLayout); // Update the Preferences data refresh(); // Redraw the screen from Preferences dialog.dismiss(); // Close the dialog } }) .setNegativeButton( R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); builder.show(); } }); refresh(); return v; }
/** 绑定事件 */ private void BindControls() { // 刷新 blog_refresh_btn.setOnClickListener( new OnClickListener() { public void onClick(View v) { new PageTask(1, true).execute(); } }); // 上拉刷新 ((PullToRefreshListView) listView) .setOnRefreshListener( new OnRefreshListener() { @Override public void onRefresh() { new PageTask(-1, true).execute(); } }); // 下拉刷新 listView.setOnScrollListener( new OnScrollListener() { /** 下拉到最后一行 */ @Override public void onScrollStateChanged(AbsListView view, int scrollState) { if (lastItem == adapter.getCount() && scrollState == OnScrollListener.SCROLL_STATE_IDLE) { pageIndex = pageIndex + 1; new PageTask(pageIndex, false).execute(); } } @Override public void onScroll( AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { lastItem = firstVisibleItem - 2 + visibleItemCount; } }); // 点击跳转 listView.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View v, int position, long id) { RedirectDetailActivity(v); } }); // 长按事件 listView.setOnCreateContextMenuListener( new OnCreateContextMenuListener() { @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.blog_list_contextmenu, menu); menu.setHeaderTitle(R.string.menu_bar_title); } }); }
protected void setListeners() { saveButton.setOnClickListener(this); itemListView.setOnCreateContextMenuListener( new OnCreateContextMenuListener() { @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { menu.add(0, MENUITEM_ID_DELETE, 0, "削除"); menu.add(0, MENUITEM_ID_MOD, 0, "変更"); } }); }
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // AlbumAdapter mArtistAlbumAdapter = new ArtistAlbumAdapter( getActivity(), R.layout.listview_items, null, new String[] {}, new int[] {}, 0); mListView.setOnCreateContextMenuListener(this); mListView.setAdapter(mArtistAlbumAdapter); mListView.setOnItemClickListener(this); // Important! getLoaderManager().initLoader(0, null, this); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = this.getIntent(); setContentView(R.layout.facebook_friends_ui); friendList = (ListView) this.findViewById(R.id.facebook_user_list); friendList.setFocusableInTouchMode(true); friendList.setFocusable(true); friendList.setOnCreateContextMenuListener(this); friendList.setOnItemClickListener(listItemClickListener); friendList.setOnScrollListener(scrollListener); current_postion = (TextView) this.findViewById(R.id.current_postion); // current_postion.setVisibility(View.GONE); searchSpan = this.findViewById(R.id.facebook_search_span); searchSpan.setVisibility(View.VISIBLE); keyEdit = (EditText) this.findViewById(R.id.embedded_text_editor); watcher = new MyWatcher(); keyEdit.addTextChangedListener(watcher); pageHandler = new PageHandler(); View v = findViewById(R.id.progress_horizontal); if (v != null) { progressHorizontal = (ProgressBar) v; } setTitle(""); SocialORM.Account account = orm.getFacebookAccount(); if (checkFacebookAccount(this, account)) { perm_session = loginHelper.getPermanentSesstion(this); if (perm_session != null) { perm_session.attachActivity(this); facebookA = new AsyncFacebook(perm_session); handler.obtainMessage(FACEBOOK_PAGE_UI).sendToTarget(); Cursor tmp = orm.getAllPageCursor(); if (tmp == null || tmp.getCount() == 0) { Log.d(TAG, "I have no data, so load from web server"); lauchGetPages(); } } else { launchFacebookLogin(); } } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.submenu_settings); mListView = (ListView) findViewById(android.R.id.list); mInflater = getLayoutInflater(); SubMenuDBHelper hlp = new SubMenuDBHelper(this); mDatabase = hlp.getWritableDatabase(); Log.d("SubMenuSettings", "Loaded db " + mDatabase.getPath()); dlg = ProgressDialog.show(this, "Please wait...", "Loading applications..."); InsertAllApps(); refreshCursor(); refreshMenuList(mDatabase); dlg.cancel(); Log.d("SubMenuSettings", "Count: " + mCursorSubMenus.getCount()); mListView.setOnCreateContextMenuListener( new OnCreateContextMenuListener() { public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { refreshMenuList(mDatabase); menu.add(0, mnuMoveItem, 0, "Add to main menu"); int i = 1; while (mCursorSubMenus.moveToNext()) { menu.add( 0, mnuMoveItem + i, 0, "Add to submenu " + mCursorSubMenus.getString(mCursorSubMenus.getColumnIndex("name"))); i++; } } }); }
/** {@inheritDoc} */ @Override public View onCreateView( final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { // The View for the fragment's UI mRootView = (ViewGroup) inflater.inflate(R.layout.list_base, null); // Initialize the list mListView = (ListView) mRootView.findViewById(R.id.list_base); // Set the data behind the list mListView.setAdapter(mAdapter); // Release any references to the recycled Views mListView.setRecyclerListener(new RecycleHolder()); // Listen for ContextMenus to be created mListView.setOnCreateContextMenuListener(this); // Play the selected song mListView.setOnItemClickListener(this); return mRootView; }
private void initUI() { mFileOperationHelper = FileOperationHelper.getInstance(this); mFileOperationHelper.setSearchContext(this); mFileSettingsHelper = FileSettingsHelper.getInstance(this); mFileSortHelper = FileSortHelper.getInstance(mFileSettingsHelper); mFileSDCardHelper = FileSDCardHelper.getInstance(this, mFileSettingsHelper, mFileOperationHelper); mFileIconHelper = new FileIconHelper(this); mSearchListView = (ListView) findViewById(R.id.search_listview); mSearchButton = (ImageView) findViewById(R.id.search); mKeywordsEdit = (EditText) findViewById(R.id.text_keyword); mImm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); mSearchButton.setOnClickListener(this); mAdapter = new SearchListAdapter(this); mSearchListView.setAdapter(mAdapter); mSearchListView.setOnItemClickListener(this); mSearchListView.setOnCreateContextMenuListener(this); }
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.facebook_event_ui); contentList = (ListView) this.findViewById(R.id.facebook_event_list); contentList.setFocusableInTouchMode(true); contentList.setFocusable(true); contentList.setOnCreateContextMenuListener(this); contentList.setOnItemClickListener(itemClick); infoSpan = (View) findViewById(R.id.facebook_info_span); eventinfoview = (TextView) findViewById(R.id.facebook_info); fornotification = this.getIntent().getBooleanExtra("fornotification", false); eids = this.getIntent().getLongArrayExtra("eids"); setTitle(); setTitle(title); SocialORM.Account account = orm.getFacebookAccount(); if (checkFacebookAccount(this, account)) { perm_session = loginHelper.getPermanentSesstion(this); if (perm_session != null) { perm_session.attachActivity(this); facebookA = new AsyncFacebook(perm_session); if (fornotification == true) { event = orm.getFacebookeventsNotificationCursor(eids); if (event != null && event.getCount() > 0) { handler.obtainMessage(FACEBOOK_EVENT_UI).sendToTarget(); } launchLoadEvents(); } else { event = orm.getFacebookeventsCursor(); if (event == null || event.getCount() == 0) { launchLoadEvents(); } else { handler.obtainMessage(FACEBOOK_EVENT_UI).sendToTarget(); } } } else { launchFacebookLogin(); } } }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_itemlist, null); ButterKnife.bind(this, v); emptyProgressView.setColors( getResources().getColor(R.color.refresh_1), getResources().getColor(R.color.refresh_2), getResources().getColor(R.color.refresh_3), getResources().getColor(R.color.refresh_4)); View headerView = inflater.inflate(R.layout.row_loading_throbber, null); headerProgressView = (ProgressThrobber) headerView.findViewById(R.id.itemlist_loading_throb); headerProgressView.setColors( getResources().getColor(R.color.refresh_1), getResources().getColor(R.color.refresh_2), getResources().getColor(R.color.refresh_3), getResources().getColor(R.color.refresh_4)); itemList.addHeaderView(headerView, null, false); itemList.setHeaderDividersEnabled(false); View footerView = inflater.inflate(R.layout.row_loading_throbber, null); footerProgressView = (ProgressThrobber) footerView.findViewById(R.id.itemlist_loading_throb); footerProgressView.setColors( getResources().getColor(R.color.refresh_1), getResources().getColor(R.color.refresh_2), getResources().getColor(R.color.refresh_3), getResources().getColor(R.color.refresh_4)); itemList.addFooterView(footerView, null, false); itemList.setFooterDividersEnabled(false); itemList.setEmptyView(v.findViewById(R.id.empty_view)); setupBezelSwipeDetector(itemList); itemList.setOnScrollListener(this); itemList.setOnItemClickListener(this); itemList.setOnCreateContextMenuListener(this); if (adapter != null) { // normally the adapter is set when it is created in onLoadFinished(), but sometimes // onCreateView gets re-called thereafter. itemList.setAdapter(adapter); } return v; }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent(); int GroupIndex = intent.getIntExtra( EXTRA_CATALOGUE_INDEX, AppCatalogueFilters.getInstance().getDrawerFilter().getCurrentFilterIndex()); mCatalogue = AppCatalogueFilters.getInstance().getCatalogue(GroupIndex); if (mCatalogue == null) { setResult(RESULT_CANCELED); finish(); return; } requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); setContentView(R.layout.app_group_conf_list); getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title1); List<AppListInfo> appInfos = new ArrayList<AppListInfo>(); /* list info */ mAppInfoAdapter = new ApplicationListAdapter(this, appInfos); mAppInfoList = getListView(); setListAdapter(mAppInfoAdapter); mAppInfoList.setOnCreateContextMenuListener(this); mAppInfoList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); /* button info */ mOkButton = ((Button) findViewById(R.id.Button_Ok_App)); mOkButton.setOnClickListener(this); CheckBox cb = (CheckBox) findViewById(R.id.checkAll); cb.setOnCheckedChangeListener( new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { updateAppList(isChecked); } }); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); updateAppList(); }
private void createHistoryView() { historyListView = (ListView) findViewById(R.id.historyList); View pointControls = getLayoutInflater().inflate(R.layout.point_controls, null); historyListView.addHeaderView(pointControls, null, false); if (getHistoryOfSearchedLocations().isEmpty()) { historyListView.addFooterView(getEmptyHistoryFooter(), null, false); } historyListView.setAdapter(getDestionationHistoryAdapter()); historyListView.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { Object selection = arg0.getItemAtPosition(arg2); if (selection instanceof cgDestination) { navigateTo(((cgDestination) selection).getCoords()); } } }); final Activity thisActivity = this; historyListView.setOnCreateContextMenuListener( new OnCreateContextMenuListener() { @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { SubMenu subMenu = menu.addSubMenu( Menu.NONE, CONTEXT_MENU_NAVIGATE, Menu.NONE, res.getString(R.string.cache_menu_navigate)); NavigationAppFactory.addMenuItems(subMenu, thisActivity, res); menu.add(Menu.NONE, CONTEXT_MENU_EDIT_WAYPOINT, Menu.NONE, R.string.waypoint_edit); menu.add(Menu.NONE, CONTEXT_MENU_DELETE_WAYPOINT, Menu.NONE, R.string.waypoint_delete); } }); }
@Override @SuppressWarnings("unchecked") public void onViewCreated(View view, Bundle savedInstanceState) { // set up the data list final ListView lv = getListView(); // define the appearance of each element setListAdapter( new SimpleAdapter( getActivity(), _listData, R.layout.list_item, new String[] {"displayName", "value"}, new int[] {R.id.item_title, R.id.item_subtitle})); // define the appearance of the onClick popup details box lv.setOnCreateContextMenuListener( new View.OnCreateContextMenuListener() { public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; HashMap<String, String> item = (HashMap<String, String>) lv.getAdapter().getItem(info.position); menu.setHeaderTitle(item.get("displayName")); menu.add("Machine Name: " + item.get("machineName")); menu.add("Value: " + item.get("value")); } }); // show the details box on item click lv.setOnItemClickListener( new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { parent.showContextMenuForChild(view); } }); }
/** {@inheritDoc} */ @Override public View onCreateView( final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { // The View for the fragment's UI mRootView = (ViewGroup) inflater.inflate(R.layout.list_base, null); // Initialize the list mListView = (ListView) mRootView.findViewById(R.id.list_base); // Set the data behind the list mListView.setAdapter(mAdapter); // Release any references to the recycled Views mListView.setRecyclerListener(new RecycleHolder()); // Listen for ContextMenus to be created mListView.setOnCreateContextMenuListener(this); // Play the selected song mListView.setOnItemClickListener(this); // To help make scrolling smooth mListView.setOnScrollListener(new VerticalScrollListener(null, mProfileTabCarousel, 0)); // Remove the scrollbars and padding for the fast scroll mListView.setVerticalScrollBarEnabled(false); mListView.setFastScrollEnabled(false); mListView.setPadding(0, 0, 0, 0); return mRootView; }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.portslist); dbadapter = new DBAdapter(this.getApplicationContext()); dbadapter.open(); portList = (ListView) findViewById(R.id.ListView01); hostInfo = (TextView) findViewById(R.id.TextView01); portList.setOnCreateContextMenuListener(this); portList.setChoiceMode(ListView.CHOICE_MODE_SINGLE); portList.setClickable(true); Bundle extras = getIntent().getExtras(); // extras should ALWAYS contain hostID and hostName hostID = extras.getLong(DBAdapter.KEY_HOST_ID); hostName = extras.getString(DBAdapter.KEY_HOST); hostInfo.setText(hostInfo.getText() + " " + hostName); portList.setAdapter(updateList()); }
private void createContentList(final View fragmentView, final ContentManager contentManager) { listView = (ListView) fragmentView.findViewById(android.R.id.list); contentListItems = new ContentListViewAdapter( getActivity(), contentManager, new ContentListViewAdapter.ContentListPathProvider() { @Override public String getCurrentPath() { return currentPath; } }, new ContentListViewAdapter.ContentListCacheObserver() { @Override public void onCacheChanged() { refreshCacheSummary(); } }, R.layout.fragment_demo_user_files_browser); listView.setAdapter(contentListItems); listView.setOnItemClickListener(this); listView.setOnCreateContextMenuListener(this); }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_itemlist, null); ListView itemList = (ListView) v.findViewById(R.id.itemlistfragment_list); itemList.setEmptyView(v.findViewById(R.id.empty_view)); contentResolver = getActivity().getContentResolver(); Uri storiesUri = FeedProvider.FEED_STORIES_URI.buildUpon().appendPath(feedId).build(); Cursor storiesCursor = contentResolver.query( storiesUri, null, DatabaseConstants.getStorySelectionFromState(currentState), null, DatabaseConstants.getStorySortOrder(storyOrder)); Uri feedUri = FeedProvider.FEEDS_URI.buildUpon().appendPath(feedId).build(); Cursor feedCursor = contentResolver.query(feedUri, null, null, null, null); if (feedCursor.getCount() < 1) { // This shouldn't happen, but crash reports indicate that it does (very rarely). // If we are told to create an item list for a feed, but then can't find that feed ID in the // DB, // something is very wrong, and we won't be able to recover, so just force the user back to // the // feed list until we have a better understanding of how to prevent this. Log.w(this.getClass().getName(), "Feed not found in DB, can't create item list."); getActivity().finish(); return v; } feedCursor.moveToFirst(); Feed feed = Feed.fromCursor(feedCursor); String[] groupFrom = new String[] { DatabaseConstants.STORY_TITLE, DatabaseConstants.STORY_AUTHORS, DatabaseConstants.STORY_READ, DatabaseConstants.STORY_SHORTDATE, DatabaseConstants.STORY_INTELLIGENCE_AUTHORS }; int[] groupTo = new int[] { R.id.row_item_title, R.id.row_item_author, R.id.row_item_title, R.id.row_item_date, R.id.row_item_sidebar }; // create the adapter before starting the loader, since the callback updates the adapter adapter = new FeedItemsAdapter( getActivity(), feed, R.layout.row_item, storiesCursor, groupFrom, groupTo, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER); getLoaderManager().initLoader(ITEMLIST_LOADER, null, this); itemList.setOnScrollListener(this); adapter.setViewBinder(new FeedItemViewBinder(getActivity())); itemList.setAdapter(adapter); itemList.setOnItemClickListener(this); itemList.setOnCreateContextMenuListener(this); return v; }
/* * 实例化控件 */ private void initCompent() { setTitleContent(R.drawable.back_btn, true, R.drawable.map_favorite_btn, R.string.my_favorite); if (isShowRighIcon) { mRightBtn.setVisibility(View.VISIBLE); mRightBtn.setOnClickListener(this); } else { mRightBtn.setVisibility(View.GONE); } mLeftBtn.setOnClickListener(this); mSearchBtn.setOnClickListener(this); mListLayout = (LinearLayout) findViewById(R.id.category_linear); mRefreshViewLastUpdated = (TextView) findViewById(R.id.pull_to_refresh_time); mContainer = (MyPullToRefreshListView) findViewById(R.id.container); mListView = mContainer.getList(); mListView.setDivider(mContext.getResources().getDrawable(R.drawable.splite)); mListView.setCacheColorHint(0); mListView.setSelector(mContext.getResources().getDrawable(R.drawable.transparent_selector)); mListView.setOnItemClickListener(this); mListView.setOnCreateContextMenuListener(this); mContainer.setOnChangeStateListener(this); mListView.setHeaderDividersEnabled(false); mListView.setOnScrollListener( new OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { // TODO Auto-generated method stub switch (scrollState) { case OnScrollListener.SCROLL_STATE_IDLE: // 处理加载更多 if (view.getLastVisiblePosition() == (view.getCount() - 1)) { if (mWeibo != null && mWeibo.page != null && mWeibo.page.hasMore == 1) { if (mFootView != null) { Message message = new Message(); message.what = GlobalParam.SHOW_LOADINGMORE_INDECATOR; message.obj = mFootView; mCheckHandler.sendMessage(message); } } else { mCheckHandler.sendEmptyMessage(GlobalParam.MSG_CHECK_STATE); } } break; default: break; } } @Override public void onScroll( AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {} }); mMapLayout = (LinearLayout) findViewById(R.id.map_category_linear); mRefreshScrollViewLastUpdated = (TextView) findViewById(R.id.scrollview_pull_to_refresh_time); mScrollContainer = (MyPullToRefreshScrollView) findViewById(R.id.scrollview_container); mScrollContainer.setOnChangeStateListener(this); mScrollView = mScrollContainer.getScrollView(); mLayout = mScrollView.getLayout(); }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_party_list, container, false); // Wire up widgets srchPartyET = (EditText) rootView.findViewById(R.id.fragment_party_list_search_et); srchPartyET.addTextChangedListener( new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // filter the list below mPartyAdapter.getFilter().filter(s); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {} @Override public void afterTextChanged(Editable s) {} }); mPartyLV = (ListView) rootView.findViewById(R.id.fragment_party_list_party_list_lv); mPartyLV.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { // Notify the active callbacks interface (the activity, if the // fragment is attached to one) that an item has been selected. mCallbacks.onItemSelected(String.valueOf(id), view); } }); mPartyLV.setOnCreateContextMenuListener(this); refreshList(); // When user clicks on Add Party button, create a Party and pass the ID to previous activity ((Button) rootView.findViewById(R.id.fragment_party_list_add_party_btn)) .setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { String name = srchPartyET.getText().toString(); Party newParty = mServices.addParty(name); UtilsView.toast(getActivity(), name + " saved."); mPartyAdapter.add(newParty); mPartyAdapter.notifyDataSetChanged(); } }); FloatingActionButton newPartyFAB = (FloatingActionButton) rootView.findViewById(R.id.fragment_party_list_fab); newPartyFAB.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Intent newPartyIntent = new Intent(getActivity(), PartyActivity.class); startActivityForResult(newPartyIntent, REQUEST_PARTY_INFO_CHGD); } }); return rootView; }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // open up the DbAdaptor db.open(); // gives us more screen space requestWindowFeature(Window.FEATURE_NO_TITLE); // need to do this because the camera doesn't do portrait mode setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); // initialize all our views. LayoutInflater inflater = getLayoutInflater(); viewCaptureNote = inflater.inflate(R.layout.view_capture_note, null); viewNote = inflater.inflate(R.layout.view_note, null); viewTagList = inflater.inflate(R.layout.view_tag_list, null); viewNoteGallery = inflater.inflate(R.layout.view_note_gallery, null); // set the content view initially to save notes setContentView(viewCaptureNote); // set up the click listeners for the camera preview screen CameraPreview cameraPreview = (CameraPreview) findViewById(R.id.surface); findViewById(R.id.discard).setOnClickListener(cameraPreview); findViewById(R.id.take).setOnClickListener(cameraPreview); findViewById(R.id.save_untagged).setOnClickListener(cameraPreview); findViewById(R.id.save_and_tag).setOnClickListener(cameraPreview); // set up the 'view untagged' option in the list menu View someView = viewTagList.findViewById(R.id.tag_list_untagged); someView.findViewById(R.id.tag_subtags).setVisibility(View.GONE); ((TextView) someView.findViewById(R.id.tag_name)).setText("Click to view untagged notes"); someView.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { Gallery g = (Gallery) viewNoteGallery.findViewById(R.id.note_gallery); g.setAdapter(new NoteGalleryImageAdaptor(SBActivity.this, db.getUntaggedNotes())); setContentView(viewNoteGallery); } }); // set the list adaptor for our tag list final ListView lv = (ListView) viewTagList.findViewById(R.id.item_list); lv.setAdapter(new TagViewListAdaptor(this, db.getTagList())); registerForContextMenu(lv); lv.setOnItemClickListener( new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { TextView v = (TextView) view.findViewById(R.id.tag_subtags); v.setVisibility(v.getVisibility() == View.VISIBLE ? View.GONE : View.VISIBLE); long tagId = (Long) view.findViewById(R.id.tag_name).getTag(); if (v.getVisibility() == View.VISIBLE) { int subtagCount = 0; StringBuilder subTags = new StringBuilder("Sub-tags: "); Cursor c = db.getSubTags(tagId); while (c.moveToNext()) { subTags.append(c.getString(1) + " "); subtagCount++; } if (subtagCount > 0) v.setText(subTags); else v.setText("No sub-tags."); } } }); lv.setOnCreateContextMenuListener( new View.OnCreateContextMenuListener() { public void onCreateContextMenu( ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { menu.setHeaderIcon(android.R.drawable.ic_menu_info_details); ListView lv = (ListView) viewTagList.findViewById(R.id.item_list); Cursor listItem = (Cursor) lv.getItemAtPosition(((AdapterView.AdapterContextMenuInfo) menuInfo).position); String tagName = listItem.getString(1); menu.setHeaderTitle("Tag '" + tagName + "'"); menu.add(0, CONTEXT_VIEW_NOTES, 0, "View notes tagged with '" + tagName + "'"); menu.add(0, CONTEXT_DELETE_TAG, 0, "Delete tag"); } }); // set up click listeners for add tag viewTagList .findViewById(R.id.save_tag) .setOnClickListener( new View.OnClickListener() { public void onClick(View view) { EditText editText = (EditText) viewTagList.findViewById(R.id.tag_id); if (editText.getText().length() == 0) return; db.addNewTag(editText.getText()); ((TagViewListAdaptor) lv.getAdapter()).refreshData(); Toast.makeText( SBActivity.this, "Tag '" + editText.getText() + "' added.", Toast.LENGTH_SHORT) .show(); editText.setText(""); } }); viewTagList.setOnFocusChangeListener( new View.OnFocusChangeListener() { @Override public void onFocusChange(View view, boolean b) { Log.i(TAG, "Focus changed innit: " + b); if (b) ((TagViewListAdaptor) lv.getAdapter()).refreshData(); } }); // set up our note viewing gallery final Gallery g = (Gallery) viewNoteGallery.findViewById(R.id.note_gallery); g.setOnItemSelectedListener( new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { // set the note number i.e. 1/3 ((TextView) viewNoteGallery.findViewById(R.id.gallery_note_number)) .setText((i + 1) + " / " + g.getCount()); // set the date field Date d = new Date(((Note) view.getTag()).getSaveTime()); ((TextView) viewNoteGallery.findViewById(R.id.gallery_note_date)) .setText(DateFormat.getDateTimeInstance().format(d)); // set the tag field Cursor c = db.getTagListForImg(l); StringBuilder sb = new StringBuilder(); while (c.moveToNext()) { if (c.getInt(2) == 0) continue; sb.append(c.getString(1)); sb.append(", "); } // delete the last 2 chars: ", " if (sb.length() > 0) sb.delete(sb.length() - 2, sb.length()); else sb.append("none"); ((TextView) viewNoteGallery.findViewById(R.id.gallery_note_tags)) .setText(sb.toString()); } @Override public void onNothingSelected(AdapterView<?> adapterView) {} }); g.setOnItemLongClickListener( new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) { return true; } }); viewNoteGallery .findViewById(R.id.note_gallery_examine) .setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { Note n = (Note) ((View) g.getSelectedView()).getTag(); setViewSingleNote(n.getFileName()); } }); Handler btProgressHandler = new Handler() { public void handleMessage(Message msg) { if (btProgressDialog == null) return; switch (msg.what) { case BluetoothService.MSG_CONNECTED: btProgressDialog.setMessage("Bluetooth connected! Sending updates..."); break; case BluetoothService.MSG_RECEIVING: btProgressDialog.setMessage("Receiving updates from computer.."); break; case BluetoothService.MSG_PROGRESS: int cur = msg.arg1; int max = msg.arg2; btProgressDialog.setProgress(cur); btProgressDialog.setMax(max); break; case BluetoothService.MSG_DONE: btProgressDialog.dismiss(); break; } } }; bService.setProgressHandler(btProgressHandler); }
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); if (V) Log.v(TAG, "onCreate ++"); setContentView(R.layout.bluetooth_transfers_page); mListView = (ListView) findViewById(R.id.list); mListView.setEmptyView(findViewById(R.id.empty)); mShowAllIncoming = getIntent().getBooleanExtra(Constants.EXTRA_SHOW_ALL_FILES, false); String direction; int dir = getIntent().getIntExtra("direction", 0); mDir = dir; if (dir == BluetoothShare.DIRECTION_OUTBOUND) { setTitle(getText(R.string.outbound_history_title)); direction = "(" + BluetoothShare.DIRECTION + " == " + BluetoothShare.DIRECTION_OUTBOUND + ")"; } else { if (mShowAllIncoming) { setTitle(getText(R.string.btopp_live_folder)); } else { setTitle(getText(R.string.inbound_history_title)); } direction = "(" + BluetoothShare.DIRECTION + " == " + BluetoothShare.DIRECTION_INBOUND + ")"; } String selection = BluetoothShare.STATUS + " >= '200' AND " + direction; if (!mShowAllIncoming) { selection = selection + " AND (" + BluetoothShare.VISIBILITY + " IS NULL OR " + BluetoothShare.VISIBILITY + " == '" + BluetoothShare.VISIBILITY_VISIBLE + "')"; } final String sortOrder = BluetoothShare.TIMESTAMP + " DESC"; mTransferCursor = managedQuery( BluetoothShare.CONTENT_URI, new String[] { "_id", BluetoothShare.FILENAME_HINT, BluetoothShare.STATUS, BluetoothShare.TOTAL_BYTES, BluetoothShare._DATA, BluetoothShare.TIMESTAMP, BluetoothShare.VISIBILITY, BluetoothShare.DESTINATION, BluetoothShare.DIRECTION }, selection, sortOrder); // only attach everything to the listbox if we can access // the transfer database. Otherwise, just show it empty if (mTransferCursor != null) { mIdColumnId = mTransferCursor.getColumnIndexOrThrow(BluetoothShare._ID); // Create a list "controller" for the data mTransferAdapter = new BluetoothOppTransferAdapter(this, R.layout.bluetooth_transfer_item, mTransferCursor); mListView.setAdapter(mTransferAdapter); mListView.setScrollBarStyle(View.SCROLLBARS_INSIDE_INSET); mListView.setOnCreateContextMenuListener(this); mListView.setOnItemClickListener(this); } mNotifier = new BluetoothOppNotification(this); }
private void init() { initData(); // 初始化UIheader iv_status = (ImageView) findViewById(R.id.imageView1); noticePaopao = (TextView) findViewById(R.id.notice_paopao); imageView = (ImageView) findViewById(R.id.top_bar_select); headIcon = (ImageView) findViewById(R.id.head_icon); headIcon.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setClass(ContacterMainActivity.this, UserInfoActivity.class); startActivity(intent); } }); // 初始化UIbody tab1 = (ImageView) findViewById(R.id.tab1); tab2 = (ImageView) findViewById(R.id.tab2); tab3 = (ImageView) findViewById(R.id.tab3); getMyApplication().addActivity(this); inflater = LayoutInflater.from(this); layout = (ScrollLayout) findViewById(R.id.scrolllayout); layout.addChangeListener(this); View contacterTab1 = inflater.inflate(R.layout.contacter_tab1, null); View contacterTab2 = inflater.inflate(R.layout.contacter_tab2, null); View contacterTab3 = inflater.inflate(R.layout.contacter_tab3, null); layout.addView(contacterTab1); layout.addView(contacterTab2); layout.addView(contacterTab3); layout.setToScreen(1); // 我的好友 contacterList = (ExpandableListView) findViewById(R.id.main_expand_list); expandAdapter = new ContacterExpandAdapter(this, rGroups); contacterList.setAdapter(expandAdapter); contacterList.setOnCreateContextMenuListener(onCreateContextMenuListener); contacterList.setOnChildClickListener(new OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { createChat((User) v.findViewById(R.id.username).getTag()); return false; } }); // 最近联系人 inviteList = (ListView) findViewById(R.id.main_invite_list); inviteNotices = MessageManager.getInstance(this) .getRecentContactsWithLastMsg(); noticeAdapter = new RecentChartAdapter(this, inviteNotices); inviteList.setAdapter(noticeAdapter); noticeAdapter.setOnClickListener(contacterOnClickJ); // 聊天室列表 chatRoomListView = (ListView) findViewById(R.id.main_chat_room_list); chatRoomAdapter = new ArrayAdapter<String>(this, R.layout.chat_room_listview_item, roomNames); chatRoomListView.setAdapter(chatRoomAdapter); chatRoomListView.setOnCreateContextMenuListener(onCreateContextMenuListener); chatRoomListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { } }); textViewCreateRoom = (TextView) findViewById(R.id.textView_create_room); textViewCreateRoom.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { addChatRoom(); } }); }