@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); sGrid = new GridView(getActivity()); sGrid.setNumColumns(KJEmojiConfig.COLUMNS); adapter = new EmojiGridAdapter(getActivity(), datas); sGrid.setAdapter(adapter); sGrid.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { EditText editText = (EditText) getActivity().findViewById( R.id.emoji_titile_input); if (listener != null) { listener.onEmojiClick((Emojicon) parent.getAdapter() .getItem(position)); } if (editText != null) InputHelper.input2OSC(editText, (Emojicon) parent.getAdapter() .getItem(position)); } }); sGrid.setSelector(R.drawable.ic_material); return sGrid; }
private GridView getViewPagerItem(final int index) { GridView gridView = new GridView(_context); gridView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); gridView.setNumColumns(4); gridView.setVerticalScrollBarEnabled(false); gridView.setHorizontalScrollBarEnabled(false); gridView.setPadding(8, 8, 8, 0); gridView.setVerticalSpacing(20); gridView.setSelector(new ColorDrawable(Color.TRANSPARENT)); gridView.setAdapter(new YayaEmoGridViewAdapter(_context, getGridViewData(index))); gridView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { int start = index * SysConstant.yayaPageSize; onEmoGridViewItemClick.onItemClick(position + start, index); } }); return gridView; }
@Override public void initEvent() {//必须在onCreate方法内调用 //示例代码<<<<<<<<<<<<<<<<<<< lvDemo.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { setResult(RESULT_OK, new Intent().putExtra(RESULT_CLICKED_ITEM, position)); finish(); } }); //分页滚动示例代码<<<<<<<<<<<<<<<<<<< new PageScroller(lvDemo).init(); //分页滚动示例代码>>>>>>>>>>>>>>>>>>> //示例代码>>>>>>>>>>>>>>>>>>> }
@Override public void initEvent() {//必须在onCreate方法内调用 super.initEvent(); //示例代码<<<<<<<<<<<<<<<<<<< lvBaseList.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // //如果lvBaseList有headerView或footerView <<<<<<<<<<<<<<< // position -= lvBaseList.getHeaderViewsCount();//ListView的方法,GridView没有 // if (position < 0 || adapter == null || position >= adapter.getCount()) { // return; // } // //如果lvBaseList有headerView或footerView >>>>>>>>>>>>>>> showShortToast("选择了 " + adapter.getItem(position).getValue()); setResult(RESULT_OK, new Intent().putExtra(RESULT_CLICKED_ITEM, position)); finish(); } }); //示例代码>>>>>>>>>>>>>>>>>>> }
/** * method to generate search suggestions for the AutoCompleteTextView from * previously searched URLs */ private void initializeSearchSuggestions(final AutoCompleteTextView getUrl) { getUrl.setThreshold(1); getUrl.setDropDownWidth(-1); getUrl.setDropDownAnchor(R.id.toolbar_layout); getUrl.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { } }); getUrl.setSelectAllOnFocus(true); mSearchAdapter = new SearchAdapter(mActivity, mDarkTheme, isIncognito()); getUrl.setAdapter(mSearchAdapter); }
@Override public void initEvent() {//必须调用 super.initEvent(); lvBaseList.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { toActivity(UserActivity.createIntent(context, id)); } }); }
@Override public FDialogMenu setAdapter(BaseAdapter adapter) { lv_content.setAdapter(adapter); lv_content.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (mCallback != null) { mCallback.onClickItem(view, (int) id, FDialogMenu.this); } dismissAfterClickIfNeed(); } }); return this; }
private void initViews() { GridView gvIcons = (GridView) findViewById(R.id.icons); SimpleAdapter adapter = new SimpleAdapter(this, getIcons(), R.layout.item_editimage, new String[] { "item", "resId" }, new int[] { R.id.item_editimage_ivIcon, R.id.item_editimaeg_tvResId }); gvIcons.setAdapter(adapter); gvIcons.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { TextView tv1 = (TextView) arg1 .findViewById(R.id.item_editimaeg_tvResId); int resId = Integer.valueOf(tv1.getText().toString()); Intent intent = new Intent(); intent.putExtra(RESULT, resId); EditImageAty.this.setResult(EditImageAty.this.getIntent() .getIntExtra(C_RESULT_CODE, 0), intent); EditImageAty.this.finish(); } }); }
private void setUpHistory() { registerForContextMenu(mHistoryView); mHistoryView.setAdapter(mHistoryAdapter); mHistoryView.setTranscriptMode(ListView.TRANSCRIPT_MODE_ALWAYS_SCROLL); mHistoryView.setStackFromBottom(true); mHistoryView.setFocusable(false); mHistoryView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { int deleteMode = mLogic.getDeleteMode(); if(mDisplay.getText().isEmpty()) deleteMode = Logic.DELETE_MODE_CLEAR; mDisplay.insert(((HistoryLine) view).getHistoryEntry().getEdited()); mLogic.setDeleteMode(deleteMode); } }); }
public DietPopView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); this.mRecords = new ArrayList(); this.itemClickListener = new OnItemClickListener() { public void onItemClick(AdapterView<?> adapterView, View view, final int position, long id) { if (position >= DietPopView.this.adapter.startPosition() && position < DietPopView.this.adapter.endPosition()) { if (DietPopView.this.dateClickListener != null) { DietPopView.this.postDelayed(new Runnable() { public void run() { DietPopView.this.dateClickListener.onDateClick(DietPopView.this .adapter.getDate(position)); } }, 500); } DietPopView.this.dateClickListener.onBottomClick(); DietPopView.this.dismiss(); } } }; this.context = context; LayoutInflater.from(context).inflate(R.layout.op, this); ButterKnife.inject((View) this); initListener(); }
private void initView() { this.mAdapter = new CustomCookAdapter(this, this.mDataList, this.mDataSelect); this.tvAddCustom.setText("我的菜肴"); this.blvContent.setAdapter(this.mAdapter); this.blvContent.setOnLoadMoreListener(new OnLoadMoreListener() { public void onLoadMore() { CustomCookListActivity.this.sendRequestCollection(true); } }); this.blvContent.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { CustomCookActivity.comeOnBaby(CustomCookListActivity.this.activity, ( (CustomCookItem) CustomCookListActivity.this.mDataList.get(position)).id); } }); }
private void initView() { this.listView = (ListView) this.pullRefreshLayout.getRefreshableView(); this.pullRefreshLayout.setOnRefreshListener(new OnRefreshListener<ListView>() { public void onRefresh(PullToRefreshBase<ListView> pullToRefreshBase) { StatusFavoriteFragment.this.page = 1; StatusFavoriteFragment.this.loadData(true); } }); this.pullRefreshLayout.setOnLastItemVisibleListener(new OnLastItemVisibleListener() { public void onLastItemVisible() { StatusFavoriteFragment.this.loadMoreData(false); } }); this.listView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { Intent intent = new Intent(StatusFavoriteFragment.this.getActivity(), CommentListActivity.class); intent.putExtra(CommentListActivity.POST_ID, ((Post) StatusFavoriteFragment.this .postList.get(position - 1)).id); StatusFavoriteFragment.this.startActivity(intent); } }); initAdapter(); }
private void initListView() { this.mPullToRefreshListView = (PullToRefreshListView) getView().findViewById(R.id.listview); this.mListView = (ListView) this.mPullToRefreshListView.getRefreshableView(); this.mPullToRefreshListView.setOnRefreshListener(new OnRefreshListener<ListView>() { public void onRefresh(PullToRefreshBase<ListView> pullToRefreshBase) { FansFragment.this.page = 1; FansFragment.this.getFans(); } }); this.mPullToRefreshListView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> adapterView, View arg1, int arg2, long arg3) { Intent intent = new Intent(FansFragment.this.getActivity(), UserTimelineActivity .class); intent.putExtra(UserTimelineActivity.NICK_NAME, FansFragment.this.mAdapter .getItem(arg2 - 1).nickname); FansFragment.this.startActivity(intent); } }); this.mPullToRefreshListView.setOnLastItemVisibleListener(new OnLastItemVisibleListener() { public void onLastItemVisible() { if (!FansFragment.this.isLastVisible) { FansFragment.this.getNextFans(); } } }); }
private void initListView() { this.mPullToRefreshListView = (PullToRefreshListView) getView().findViewById(R.id.listview); this.mListView = (ListView) this.mPullToRefreshListView.getRefreshableView(); this.mPullToRefreshListView.setOnRefreshListener(new OnRefreshListener<ListView>() { public void onRefresh(PullToRefreshBase<ListView> pullToRefreshBase) { FriendFragment.this.getFriends(); } }); this.mPullToRefreshListView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> adapterView, View arg1, int arg2, long arg3) { Intent intent = new Intent(FriendFragment.this.getActivity(), UserTimelineActivity.class); intent.putExtra(UserTimelineActivity.NICK_NAME, FriendFragment.this.mAdapter .getItem(arg2 - 1).nickname); FriendFragment.this.startActivity(intent); } }); this.mPullToRefreshListView.setOnLastItemVisibleListener(new OnLastItemVisibleListener() { public void onLastItemVisible() { if (!FriendFragment.this.isLastVisible) { FriendFragment.this.getNextFriends(); } } }); }
private void initView() { View headerView = LayoutInflater.from(this.ctx).inflate(R.layout.h6, null); this.ivHeader = (ImageView) headerView.findViewById(R.id.iv_header); ViewUtils.setViewScaleHeight(this.ctx, this.ivHeader, 2, 1); ((ListView) this.pullToRefreshListView.getRefreshableView()).addHeaderView(headerView); this.pullToRefreshListView.setOnRefreshListener(new OnRefreshListener<ListView>() { public void onRefresh(PullToRefreshBase<ListView> pullToRefreshBase) { SuccessStoryActivity.this.page = 1; SuccessStoryActivity.this.requestData(); } }); this.pullToRefreshListView.setOnLastItemVisibleListener(new OnLastItemVisibleListener() { public void onLastItemVisible() { SuccessStoryActivity.this.page = SuccessStoryActivity.this.page + 1; SuccessStoryActivity.this.requestData(); } }); this.pullToRefreshListView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { ItemsEntity itemsEntity = (ItemsEntity) adapterView.getAdapter().getItem(i); if (itemsEntity != null) { BooheeScheme.handleUrl(SuccessStoryActivity.this.ctx, itemsEntity.url); } } }); }
private GridView getViewPagerItem(final int index) { GridView gridView = new GridView(_context); gridView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); gridView.setNumColumns(7); gridView.setVerticalScrollBarEnabled(false); gridView.setHorizontalScrollBarEnabled(false); gridView.setPadding(8, 8, 8, 0); gridView.setVerticalSpacing(CommonUtil.getElementSzie(_context) / 2 + CommonUtil.getElementSzie(_context) / 3); // gridView.setVerticalSpacing(30); gridView.setBackgroundColor(Color.TRANSPARENT); gridView.setAdapter(new EmoGridViewAdapter(_context, getGridViewData(index))); gridView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { int start = index * (SysConstant.pageSize - 1); onEmoGridViewItemClick.onItemClick(position + start, index); } }); return gridView; }
@Override public void initEvent() {//必须调用 super.initEvent(); lvBaseList.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (id > 0) { toActivity(UserActivity.createIntent(context, id)); } } }); }
@Override public void initEvent() {//必须在onCreateView方法内调用 super.initEvent(); //示例代码<<<<<<<<<<<<<<<<<<< lvBaseList.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { toActivity(UserActivity.createIntent(context, position));//一般用id,这里position仅用于测试 id));// } }); //示例代码>>>>>>>>>>>>>>>>>>> }
@Override public void initEvent() {//必须在onCreateView方法内调用 //示例代码<<<<<<<<<<<<<<<<<<< lvDemoFragment.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { toActivity(UserActivity.createIntent(context, position));//一般用id,这里position仅用于测试 id));// } }); //示例代码>>>>>>>>>>>>>>>>>>> }
public DropdownPopup(Context context, AttributeSet attrs, int defStyleRes) { super(context, attrs, 0, defStyleRes); setAnchorView(IcsSpinner.this); setModal(true); setPromptPosition(POSITION_PROMPT_ABOVE); setOnItemClickListener(new OnItemClickListener() { @SuppressWarnings("rawtypes") public void onItemClick(AdapterView parent, View v, int position, long id) { IcsSpinner.this.setSelection(position); dismiss(); } }); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Use different items when debugging if (Utils.isDebugBuild(this)) { data = DEBUG_DATA; } // set the ListAdapter setListAdapter(new MiscAdapter(this, data)); ListView lv = getListView(); lv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int pos, long id) { if (pos < 0 || pos >= data.length) { return; } if (data[pos].activityClass == null) { Toast.makeText(getApplicationContext(), data[pos].title + " Selected", Toast.LENGTH_SHORT) .show(); } else { Intent i = new Intent(MiscActivity.this, data[pos].activityClass); try { startActivity(i); } catch (Exception ex) { Utils.excMsg(MiscActivity.this, "Error launching activity", ex); } } } }); }
@Override public void initEvent() {//必须调用 super.initEvent(); lvBaseList.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { toActivity(MomentActivity.createIntent(context, id, false)); } }); }
@Override public void initEvents() { mListDir.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (mImageDirSelected != null) { mImageDirSelected.selected(mDatas.get(position)); } } }); }
private void initUI() { this.mListView = (ListView) getContentView().findViewById(R.id.lemallsdk_title_list); this.mListView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> adapterView, View arg1, int index, long arg3) { TitlePopupMenu.this.dismiss(); if (TitlePopupMenu.this.mItemOnClickListener != null) { TitlePopupMenu.this.mItemOnClickListener.onItemClick((MenuEntity) TitlePopupMenu.this.menus.get(index), index); } } }); }
public void initListText(final PointBeanList bean) { this.list.setAdapter(new PointItemAdapter(this, bean)); this.list.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { Intent intent = new Intent(); intent.putExtra("my_points", Integer.parseInt(((PointBean) bean.get(position)).credit) * ((PointBean) bean.get(position)).state); intent.putExtra("flag", position); intent.setClass(PointsActivtiy.this, TaskDetailActivity.class); PointsActivtiy.this.startActivity(intent); } }); }
/** * method to generate search suggestions for the AutoCompleteTextView from * previously searched URLs */ private void initializeSearchSuggestions(final AutoCompleteTextView getUrl) { mSuggestionsAdapter = new SuggestionsAdapter(this, mDarkTheme, isIncognito()); getUrl.setThreshold(1); getUrl.setDropDownWidth(-1); getUrl.setDropDownAnchor(R.id.toolbar_layout); getUrl.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int pos, long l) { String url = null; CharSequence urlString = ((TextView) view.findViewById(R.id.url)).getText(); if (urlString != null) { url = urlString.toString(); } if (url == null || url.startsWith(getString(R.string.suggestion))) { CharSequence searchString = ((TextView) view.findViewById(R.id.title)).getText(); if (searchString != null) { url = searchString.toString(); } } if (url == null) { return; } getUrl.setText(url); searchTheWeb(url); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(getUrl.getWindowToken(), 0); mPresenter.onAutoCompleteItemPressed(); } }); getUrl.setSelectAllOnFocus(true); getUrl.setAdapter(mSuggestionsAdapter); }
private void initView() { errorLayout.setOnLayoutClickListener(new OnClickListener() { @Override public void onClick(View v) { requestData(true); } }); listview.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Bundle args = new Bundle(); args.putInt(TeamDiaryFragment.TEAMID_KEY, teamId); args.putSerializable(TeamDiaryFragment.DIARYDETAIL_KEY, datas .getList().get(position)); UIHelper.showDiaryDetail(cxt, args); } }); pullHeadView.setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh() { if (BaseFragment.mState == BaseFragment.STATE_REFRESH) { return; } else { errorLayout.setErrorMessage("本周无人提交周报"); // // 设置顶部正在刷新 // setSwipeRefreshLoadingState(pullHeadView); requestData(false); } } }); pullHeadView.setColorSchemeResources(R.color.swiperefresh_color1, R.color.swiperefresh_color2, R.color.swiperefresh_color3, R.color.swiperefresh_color4); }
private void onClickListener() { mListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { isShowListView(); resolutionMap = cameraSize.get(position); String str = resolutionMap.get("width") + "*" + resolutionMap.get("height"); mDialogUtil.setTextSzie(editItemTexts[1], str.length()); editItemTexts[1].setText(str); } }); }
private void findViews() { this.mList = (ListView) findViewById(R.id.contentList); this.mAdapter = new ArrayAdapter(this, 17367055, this.mData); this.mList.setAdapter(this.mAdapter); this.mList.setItemChecked(0, true); this.mList.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> adapterView, View arg1, int position, long arg3) { ReportActivity.this.category = (String) ReportActivity.this.mAdapter.getItem (position); } }); }
private void findViews() { this.clearGpsBar = (LinearLayout) getView().findViewById(R.id.clear_gps_bar); ((Button) getView().findViewById(R.id.clear_gps)).setOnClickListener(new OnClickListener() { public void onClick(View v) { LightAlertDialog.create(SearchFriendsFragment.this.getActivity(), SearchFriendsFragment.this.getString(R.string.o_), SearchFriendsFragment .this.getString(R.string.fm)).setNegativeButton (SearchFriendsFragment.this.getString(R.string.eq), null) .setPositiveButton(SearchFriendsFragment.this.getString(R.string.gn), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { SearchFriendsFragment.this.clearGps(); } }).show(); } }); this.mPullRefreshListView = (PullToRefreshListView) getView().findViewById(R.id.listview); this.mListView = (ListView) this.mPullRefreshListView.getRefreshableView(); this.mPullRefreshListView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> adapterView, View arg1, int arg2, long arg3) { Intent intent = new Intent(SearchFriendsFragment.this.getActivity(), UserTimelineActivity.class); intent.putExtra(UserTimelineActivity.NICK_NAME, SearchFriendsFragment.this .mFriendsAdapter.getItem(arg2 - 1).nickname); SearchFriendsFragment.this.startActivity(intent); } }); this.mPullRefreshListView.setOnRefreshListener(new OnRefreshListener<ListView>() { public void onRefresh(PullToRefreshBase<ListView> pullToRefreshBase) { SearchFriendsFragment.this.initUI(); } }); }
public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); this.listView = (ListView) this.mPullRefreshListView.getRefreshableView(); this.mAddFoodListAdapter = new FavourFoodListAdapter(getActivity(), this.mFoodList); this.listView.setAdapter(this.mAddFoodListAdapter); this.mPullRefreshListView.setOnRefreshListener(new OnRefreshListener<ListView>() { public void onRefresh(PullToRefreshBase<ListView> pullToRefreshBase) { FavourFoodFragmennt.this.mPage = 1; FavourFoodFragmennt.this.mCurrentPage = FavourFoodFragmennt.this.mPage; FavourFoodFragmennt.this.hasMore = true; FavourFoodFragmennt.this.loadData(); } }); this.mPullRefreshListView.setOnLastItemVisibleListener(new OnLastItemVisibleListener() { public void onLastItemVisible() { if (FavourFoodFragmennt.this.mPage > FavourFoodFragmennt.this.mCurrentPage) { FavourFoodFragmennt.this.mCurrentPage = FavourFoodFragmennt.this.mPage; FavourFoodFragmennt.this.loadData(); } } }); this.listView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { if (FavourFoodFragmennt.this.mFoodList != null && FavourFoodFragmennt.this .mFoodList.size() != 0 && position >= 1) { AddDietFragment.newInstance(FavourFoodFragmennt.this.mTimeType, FavourFoodFragmennt.this.record_on, ((FavourFood) FavourFoodFragmennt .this.mFoodList.get(position - 1)).code).show (FavourFoodFragmennt.this.getChildFragmentManager(), "addDietFragment"); } } }); }
private void initView() { this.mAdapter = new CollectionAdapter(this, this.mDataList, this.mDataSelect); this.blvContent.setAdapter(this.mAdapter); this.blvContent.setOnLoadMoreListener(new OnLoadMoreListener() { public void onLoadMore() { CollectionActivity.this.sendRequestCollection(true); } }); this.blvContent.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { FoodDetailActivity.comeOnBaby(CollectionActivity.this, ((CollectionFood) CollectionActivity.this.mDataList.get(position)).code, false); } }); }
public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); this.listView = (ListView) this.mPullRefreshListView.getRefreshableView(); this.mAddFoodListAdapter = new CommonFoodListAdapter(getActivity(), this.mFoodList); this.listView.setAdapter(this.mAddFoodListAdapter); this.mPullRefreshListView.setOnRefreshListener(new OnRefreshListener<ListView>() { public void onRefresh(PullToRefreshBase<ListView> pullToRefreshBase) { CommonFoodFragmennt.this.mPage = 1; CommonFoodFragmennt.this.mCurrentPage = CommonFoodFragmennt.this.mPage; CommonFoodFragmennt.this.hasMore = true; CommonFoodFragmennt.this.loadData(); } }); this.mPullRefreshListView.setOnLastItemVisibleListener(new OnLastItemVisibleListener() { public void onLastItemVisible() { if (CommonFoodFragmennt.this.mPage > CommonFoodFragmennt.this.mCurrentPage) { CommonFoodFragmennt.this.mCurrentPage = CommonFoodFragmennt.this.mPage; CommonFoodFragmennt.this.loadData(); } } }); this.listView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { if (CommonFoodFragmennt.this.mFoodList != null && CommonFoodFragmennt.this .mFoodList.size() != 0 && position >= 1 && CommonFoodFragmennt.this .isAdded() && !CommonFoodFragmennt.this.isDetached()) { AddDietFragment.newInstance(CommonFoodFragmennt.this.mTimeType, CommonFoodFragmennt.this.record_on, ((CommonFood) CommonFoodFragmennt .this.mFoodList.get(position - 1)).code).show (CommonFoodFragmennt.this.getChildFragmentManager(), "addDietFragment"); } } }); refreshData(this.mCache.getAsJSONObject(CacheKey.COMMON_FOOD)); firstLoad(); }
private void initListener() { this.calendarGrid.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { if (position >= DiamondSignActivity.this.adapter.startPosition() && position < DiamondSignActivity.this.adapter.endPosition()) { if (DiamondSignActivity.this.adapter.getDate(position).after(new Date())) { DiamondSignActivity.this.repairBtn.setEnabled(false); return; } long dayCount = DateFormatUtils.countDay(DiamondSignActivity.this.adapter .getDateString(position), DateFormatUtils.date2string(new Date(), "yyyy-MM-dd")); if (dayCount <= 0 || dayCount > 7 || DiamondSignActivity.this.adapter .isChecked(position)) { DiamondSignActivity.this.repairBtn.setEnabled(false); } else { DiamondSignActivity.this.repairBtn.setEnabled(true); DiamondSignActivity.this.repairDate = DiamondSignActivity.this.adapter .getDateString(position); } if (dayCount > 0) { DiamondSignActivity.this.adapter.setCurrentPosition(position); DiamondSignActivity.this.adapter.notifyDataSetChanged(); } } } }); }