List of usage examples for android.widget GridView setAdapter
@Override public void setAdapter(ListAdapter adapter)
From source file:com.example.android.ennis.barrett.popularmovies.MainFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Log.v(TAG, "onCreateView started"); View rootView = inflater.inflate(R.layout.fragment_main, container, false); GridView gridView = (GridView) rootView.findViewById(R.id.gridView); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); String sortBy = sharedPreferences.getString(getString(R.string.sortby_key), "-1"); Log.d(TAG, getString(R.string.sortby_key)); Log.d(TAG, "sortBy value: " + sortBy); Bundle loaderBundle = new Bundle(1); if (sortBy.equals("0")) { loaderBundle.putString(LOADER_BUNDLE_KEY, TMDbContract.Movies.IS_POPULAR); } else if (sortBy.equals("1")) { loaderBundle.putString(LOADER_BUNDLE_KEY, TMDbContract.Movies.IS_TOP_RATED); } else if (sortBy.equals("2")) { loaderBundle.putString(LOADER_BUNDLE_KEY, TMDbContract.Movies.IS_FAVORITE); } else {/*from w w w . j a v a 2s.c o m*/ Log.e(TAG, "unrecognized value from shared preference"); loaderBundle = null; } mAdapter = new GridAdapter(getActivity()); gridView.setAdapter(mAdapter); gridView.setOnItemClickListener(this); getLoaderManager().initLoader(0, loaderBundle, this); Log.v(TAG, "onCreateView ended...returning rootView"); return rootView; }
From source file:org.catnut.fragment.TweetFragment.java
@Override public boolean onMenuItemClick(MenuItem item) { // first check emotions if (item.getItemId() == R.id.action_emotions) { GridView emotions = (GridView) LayoutInflater.from(getActivity()).inflate(R.layout.emotions, null); emotions.setAdapter(new EmotionsAdapter(getActivity())); emotions.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override//from ww w .j a v a2 s . c o m public void onItemClick(AdapterView<?> parent, View view, int position, long id) { int cursor = mSendText.getSelectionStart(); mSendText.getText().insert(cursor, CatnutUtils.text2Emotion(getActivity(), TweetImageSpan.EMOTION_KEYS[position], getResources().getInteger(R.integer.icon_bound_px))); mSendText.requestFocus(); } }); AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).setView(emotions).create(); alertDialog.show(); alertDialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, getResources().getDimensionPixelSize(R.dimen.emotion_window_height)); return true; } switch (item.getItemId()) { case R.id.action_reply_none: mRetweetOption = 0; break; case R.id.action_reply_current: mRetweetOption = 1; break; case R.id.action_reply_original: mRetweetOption = 2; break; case R.id.action_reply_both: mRetweetOption = 3; break; default: break; } if (!item.isChecked()) { item.setChecked(true); } return true; }
From source file:org.messic.android.activities.fragments.RandomFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_random, container, false); getMessicService();/*from w ww . j a v a2s . c o m*/ GridView gv = (GridView) rootView.findViewById(R.id.random_gvitems); sa = new SongAdapter(getActivity(), new SongAdapter.EventListener() { public void textTouch(MDMSong song, int index) { AlbumController.getAlbumInfo(RandomFragment.this.getActivity(), song.getAlbum().getSid()); } public void coverTouch(MDMSong song, int index) { musicSrv.getPlayer().addSong(song); Toast.makeText(getActivity(), getResources().getText(R.string.player_added) + song.getName(), Toast.LENGTH_SHORT).show(); } public void coverLongTouch(MDMSong song, int index) { musicSrv.getPlayer().addAndPlay(song); } public void elementRemove(MDMSong song, int index) { // TODO Auto-generated method stub } public void playlistTouch(MDMPlaylist playlist, int index) { // TODO Auto-generated method stub } }); gv.setAdapter(sa); final SwipeRefreshLayout srl = (SwipeRefreshLayout) rootView.findViewById(R.id.random_swipe); srl.setColorSchemeColors(Color.RED, Color.GREEN, Color.BLUE, Color.CYAN); srl.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { public void onRefresh() { new Handler().post(new Runnable() { public void run() { if (getActivity() != null) { View rp = getActivity().findViewById(R.id.random_progress); if (rp != null) { rp.setVisibility(View.VISIBLE); controller.getRandomMusic(sa, getActivity(), RandomFragment.this, true, srl); } } } }); } }); return rootView; }
From source file:com.personal.coine.scorpion.jxnuhelper.view.fragment.ChargeOthersCardFragment.java
private void initViews(View view) { final TextView userName = (TextView) view.findViewById(R.id.others_name); othersBalance = (TextView) view.findViewById(R.id.others_balance); final AppCompatEditText userInputCardNumber = (AppCompatEditText) view .findViewById(R.id.et_user_card_number); userInputCardNumber.addTextChangedListener(new TextWatcher() { @Override/*from w ww. j a v a2s .co m*/ public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (s.length() == 10) { queryProgress = KProgressHUD.create(getContext()) .setStyle(KProgressHUD.Style.SPIN_INDETERMINATE).setLabel("...") .setCancellable(false).setAnimationSpeed(2).setDimAmount(0.5f); BmobQuery<CampusCard> query = new BmobQuery<CampusCard>(); query.addWhereEqualTo("cardNumber", s.toString()); query.findObjects(getContext(), new FindListener<CampusCard>() { @Override public void onSuccess(List<CampusCard> list) { chargeUser = list.get(0).getOwner(); BmobQuery<MyUser> userQuery = new BmobQuery<MyUser>(); userQuery.addWhereEqualTo("objectId", chargeUser.getObjectId()); userQuery.findObjects(getContext(), new FindListener<MyUser>() { @Override public void onSuccess(List<MyUser> list) { queryProgress.dismiss(); chargeUser = list.get(0); userName.setText(chargeUser.getUsername()); chargePresenter.loadCardInfo(); } @Override public void onError(int i, String s) { queryProgress.dismiss(); Log.e(TAG, "??" + s); Toast.makeText(getContext(), "?", Toast.LENGTH_SHORT).show(); } }); } @Override public void onError(int i, String s) { queryProgress.dismiss(); Toast.makeText(getContext(), "?,", Toast.LENGTH_SHORT).show(); Log.e(TAG, "" + s); } }); } } @Override public void afterTextChanged(Editable s) { } }); GridView chargeAmount = (GridView) view.findViewById(R.id.others_charge_amount); List<Map<String, Object>> dataList = new ArrayList<>(); final String[] titleArray = new String[] { "10", "20", "30", "50", "100", "200", "300", "500" }; String[] contentArray = new String[] { ":10.00", ":20.00", ":29.94", ":49.85", ":99.75", ":199.60", ":299.00", ":498.00" }; for (int i = 0; i < titleArray.length; i++) { Map<String, Object> map = new HashMap<String, Object>(); map.put("title", titleArray[i]); map.put("content", contentArray[i]); dataList.add(map); } SimpleAdapter adapter = new SimpleAdapter(getContext(), dataList, R.layout.grid_item, new String[] { "title", "content" }, new int[] { R.id.charge_title, R.id.charge_content }); chargeAmount.setAdapter(adapter); chargeAmount.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, final int position, long id) { AlertDialog alertDialog = new AlertDialog.Builder(getContext()).setTitle("") .setMessage("" + titleArray[position] + "?") .setPositiveButton("", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { chargeSum = Integer.valueOf( titleArray[position].substring(0, (titleArray[position].length() - 1))); chargePresenter.doCharge(); } }).setNegativeButton("?", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).show(); } }); }
From source file:org.michaelbel.bottomsheet.BottomSheet.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (backgroundColor == 0) { backgroundColor = darkTheme ? 0xFF424242 : 0xFFFFFFFF; }//from w ww. ja va 2 s . c o m if (titleTextColor == 0) { titleTextColor = darkTheme ? 0xB3FFFFFF : 0x8A000000; } if (itemTextColor == 0) { itemTextColor = darkTheme ? 0xFFFFFFFF : 0xDE000000; } if (iconColor == 0) { iconColor = darkTheme ? 0xFFFFFFFF : 0x8A000000; } if (itemSelector == 0) { itemSelector = darkTheme ? R.drawable.selectable_dark : R.drawable.selectable_light; } Window window = getWindow(); window.setWindowAnimations(R.style.DialogNoAnimation); setContentView(container, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); if (containerView == null) { containerView = new FrameLayout(getContext()) { @Override public boolean hasOverlappingRendering() { return false; } }; if (Build.VERSION.SDK_INT >= 16) { containerView.setBackground(shadowDrawable); } else { containerView.setBackgroundDrawable(shadowDrawable); } containerView.setPadding(0, backgroundPaddingTop, 0, Utils.dp(getContext(), 8)); } if (Build.VERSION.SDK_INT >= 21) { containerView.setFitsSystemWindows(true); } containerView.setVisibility(View.INVISIBLE); containerView.setBackgroundColor(backgroundColor); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.BOTTOM; containerView.setLayoutParams(params); container.addView(containerView, 0); if (customView != null) { if (customView.getParent() != null) { ViewGroup viewGroup = (ViewGroup) customView.getParent(); viewGroup.removeView(customView); } FrameLayout.LayoutParams params1 = (FrameLayout.LayoutParams) containerView.getLayoutParams(); params1.width = ViewGroup.LayoutParams.MATCH_PARENT; params1.height = ViewGroup.LayoutParams.WRAP_CONTENT; params1.gravity = Gravity.START | Gravity.TOP; containerView.addView(customView, params1); } else { int topOffset = 0; if (titleText != null) { TextView titleTextView = new TextView(getContext()); titleTextView.setLines(1); titleTextView.setMaxLines(1); titleTextView.setSingleLine(true); titleTextView.setText(titleText); titleTextView.setTextColor(titleTextColor); titleTextView.setEllipsize(TextUtils.TruncateAt.MIDDLE); titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); titleTextView.setGravity(Gravity.CENTER_VERTICAL); FrameLayout.LayoutParams params0 = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, Utils.dp(getContext(), 56)); params0.gravity = Gravity.START | Gravity.TOP; params0.leftMargin = Utils.dp(getContext(), 16); params0.rightMargin = Utils.dp(getContext(), 16); titleTextView.setLayoutParams(params0); containerView.addView(titleTextView); titleTextView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); topOffset += 56; } BottomSheetAdapter adapter = new BottomSheetAdapter(); if (mItems != null || mItemsRes != null) { if (contentType == LIST) { FrameLayout.LayoutParams params2 = new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); params2.topMargin = Utils.dp(getContext(), topOffset); ListView listView = new ListView(getContext()); listView.setSelector(itemSelector); listView.setDividerHeight(0); listView.setAdapter(adapter); listView.setDrawSelectorOnTop(true); listView.setVerticalScrollBarEnabled(false); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { dismissWithButtonClick(i); } }); listView.setLayoutParams(params2); containerView.addView(listView); } else if (contentType == GRID) { FrameLayout.LayoutParams params3 = new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); GridView gridView = new GridView(getContext()); gridView.setSelector(itemSelector); gridView.setAdapter(adapter); gridView.setNumColumns(3); gridView.setVerticalScrollBarEnabled(false); gridView.setVerticalSpacing(Utils.dp(getContext(), 16)); gridView.setPadding(Utils.dp(getContext(), 0), Utils.dp(getContext(), topOffset + 8), Utils.dp(getContext(), 0), Utils.dp(getContext(), 16)); gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { dismissWithButtonClick(i); } }); gridView.setLayoutParams(params3); containerView.addView(gridView); } if (mItems != null) { for (int a = 0; a < mItems.length; a++) { items.add(new Item(mItems[a], mIcons != null ? mIcons[a] : 0)); } } else { for (int a = 0; a < mItemsRes.length; a++) { items.add(new Item(getContext().getText(mItemsRes[a]), mIcons != null ? mIcons[a] : 0)); } } adapter.notifyDataSetChanged(); } } WindowManager.LayoutParams params4 = window.getAttributes(); params4.width = ViewGroup.LayoutParams.MATCH_PARENT; params4.gravity = Gravity.TOP | Gravity.START; params4.dimAmount = 0; params4.flags &= ~WindowManager.LayoutParams.FLAG_DIM_BEHIND; if (!focusable) { params4.flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; } params4.height = ViewGroup.LayoutParams.MATCH_PARENT; window.setAttributes(params4); }
From source file:org.digitalcampus.oppia.fragments.GlobalScorecardFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); initializeDagger();/*from ww w. j a v a2 s . c om*/ ArrayList<Course> courses = coursesRepository.getCourses(getActivity()); GridView scorecardList = (GridView) super.getActivity().findViewById(R.id.scorecards_list); View emptyState = this.getActivity().findViewById(R.id.empty_state); if (courses.size() == 0) { //If there are now courses, display the empty state scorecardList.setVisibility(View.GONE); emptyState.setVisibility(View.VISIBLE); Button download = (Button) emptyState.findViewById(R.id.btn_download_courses); download.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AdminSecurityManager.checkAdminPermission(getActivity(), R.id.menu_download, new AdminSecurityManager.AuthListener() { public void onPermissionGranted() { startActivity(new Intent(getActivity(), TagSelectActivity.class)); } }); } }); } else { scorecardList.setVisibility(View.VISIBLE); emptyState.setVisibility(View.GONE); scorecardListAdapter = new ScorecardListAdapter(super.getActivity(), courses); scorecardList.setAdapter(scorecardListAdapter); scorecardList.setOnItemClickListener(this); } }
From source file:kien.activities.DistrictAcitivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_viewdistrict); TextView tvPopulation = (TextView) findViewById(R.id.tvPopulation); TextView tvArea = (TextView) findViewById(R.id.tvArea); GridView gvDistrict = (GridView) findViewById(R.id.gvDistrict); ivBack = (ImageView) findViewById(R.id.ivBack); ivBack.setOnClickListener(new View.OnClickListener() { @Override/*from ww w. j a va 2 s . co m*/ public void onClick(View v) { onBackPressed(); } }); TextView tvNameProvince = (TextView) findViewById(R.id.tvNameProvince); Intent myIntent = getIntent(); int id = myIntent.getIntExtra("id", 0); dataBaseHelper = new DataBaseHelper(this); try { dataBaseHelper.isCreatedDatabase(); } catch (IOException e) { } int population = dataBaseHelper.getPopulationProvince(id); float area = dataBaseHelper.getAreaProvince(id); NumberFormat numberFormat = NumberFormat.getNumberInstance(); numberFormat.format(population); Log.e("NUMBER", area + ""); tvPopulation.setText(numberFormat.format(population) + " ng?i"); tvArea.setText(area + " km2"); listLicense = new ArrayList<License>(); listLicense = dataBaseHelper.getListDistrict(id); adapterLicense = new AdapterLicense(this, R.layout.fragment_license, listLicense, this); gvDistrict.setAdapter(adapterLicense); localAddress = dataBaseHelper.getAddressLocal(id); tvNameProvince.setText(localAddress + ""); //add Map; // mMapFragment = MapFragment.newInstance(); // FragmentTransaction fragmentTransaction = // getFragmentManager().beginTransaction(); // fragmentTransaction.add(R.id.map, mMapFragment); // fragmentTransaction.commit(); // mMapFragment.getMapAsync(this); // GoogleMapOptions googleMapOptions = new GoogleMapOptions(); // googleMapOptions.mapType(GoogleMap.MAP_TYPE_HYBRID).compassEnabled(true).zoomControlsEnabled(false); //googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(HANOI, 10)); //googleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE); latlongAdress = dataBaseHelper.getLatLong(id); MapFragment mapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.map); mapFragment.getMapAsync(this); googleMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap(); googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latlongAdress, 9)); Log.e("TEST", latlongAdress + " address"); Log.e("TEST", googleMap + "google"); //GoogleMap googleMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap(); googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL); googleMap.getUiSettings().setZoomControlsEnabled(true); googleMap.setMyLocationEnabled(true); }
From source file:org.telegramsecureplus.ui.Components.EmojiView.java
public EmojiView(boolean needStickers, Context context) { super(context); showStickers = needStickers;/*from w ww. j a v a 2s .c o m*/ for (int i = 0; i < Emoji.data.length; i++) { GridView gridView = new GridView(context); if (AndroidUtilities.isTablet()) { gridView.setColumnWidth(AndroidUtilities.dp(60)); } else { gridView.setColumnWidth(AndroidUtilities.dp(45)); } gridView.setNumColumns(-1); views.add(gridView); EmojiGridAdapter emojiGridAdapter = new EmojiGridAdapter(Emoji.data[i]); gridView.setAdapter(emojiGridAdapter); AndroidUtilities.setListViewEdgeEffectColor(gridView, 0xfff5f6f7); adapters.add(emojiGridAdapter); } if (showStickers) { StickersQuery.checkStickers(); GridView gridView = new GridView(context); gridView.setColumnWidth(AndroidUtilities.dp(72)); gridView.setNumColumns(-1); gridView.setPadding(0, AndroidUtilities.dp(4), 0, 0); gridView.setClipToPadding(false); views.add(gridView); stickersGridAdapter = new StickersGridAdapter(context); gridView.setAdapter(stickersGridAdapter); AndroidUtilities.setListViewEdgeEffectColor(gridView, 0xfff5f6f7); stickersWrap = new FrameLayout(context); stickersWrap.addView(gridView); TextView textView = new TextView(context); textView.setText(LocaleController.getString("NoStickers", R.string.NoStickers)); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); textView.setTextColor(0xff888888); stickersWrap.addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER)); gridView.setEmptyView(textView); scrollSlidingTabStrip = new ScrollSlidingTabStrip(context) { boolean startedScroll; float lastX; float lastTranslateX; boolean first = true; @Override public boolean onInterceptTouchEvent(MotionEvent ev) { if (getParent() != null) { getParent().requestDisallowInterceptTouchEvent(true); } return super.onInterceptTouchEvent(ev); } @Override public boolean onTouchEvent(MotionEvent ev) { if (Build.VERSION.SDK_INT >= 11) { if (first) { first = false; lastX = ev.getX(); } float newTranslationX = ViewProxy.getTranslationX(scrollSlidingTabStrip); if (scrollSlidingTabStrip.getScrollX() == 0 && newTranslationX == 0) { if (!startedScroll && lastX - ev.getX() < 0) { if (pager.beginFakeDrag()) { startedScroll = true; lastTranslateX = ViewProxy.getTranslationX(scrollSlidingTabStrip); } } else if (startedScroll && lastX - ev.getX() > 0) { if (pager.isFakeDragging()) { pager.endFakeDrag(); startedScroll = false; } } } if (startedScroll) { int dx = (int) (ev.getX() - lastX + newTranslationX - lastTranslateX); try { pager.fakeDragBy(dx); lastTranslateX = newTranslationX; } catch (Exception e) { try { pager.endFakeDrag(); } catch (Exception e2) { //don't promt } startedScroll = false; FileLog.e("tmessages", e); } } lastX = ev.getX(); if (ev.getAction() == MotionEvent.ACTION_CANCEL || ev.getAction() == MotionEvent.ACTION_UP) { first = true; if (startedScroll) { pager.endFakeDrag(); startedScroll = false; } } return startedScroll || super.onTouchEvent(ev); } return super.onTouchEvent(ev); } }; scrollSlidingTabStrip.setUnderlineHeight(AndroidUtilities.dp(1)); scrollSlidingTabStrip.setIndicatorColor(0xffe2e5e7); scrollSlidingTabStrip.setUnderlineColor(0xffe2e5e7); addView(scrollSlidingTabStrip, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.LEFT | Gravity.TOP)); ViewProxy.setTranslationX(scrollSlidingTabStrip, AndroidUtilities.displaySize.x); updateStickerTabs(); scrollSlidingTabStrip.setDelegate(new ScrollSlidingTabStrip.ScrollSlidingTabStripDelegate() { @Override public void onPageSelected(int page) { if (page == 0) { pager.setCurrentItem(0); return; } else if (page == 1 && !recentStickers.isEmpty()) { views.get(6).setSelection(0); return; } int index = page - (recentStickers.isEmpty() ? 1 : 2); if (index >= stickerSets.size()) { index = stickerSets.size() - 1; } views.get(6).setSelection(stickersGridAdapter.getPositionForPack(stickerSets.get(index))); } }); gridView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { int count = view.getChildCount(); for (int a = 0; a < count; a++) { View child = view.getChildAt(a); if (child.getHeight() + child.getTop() < AndroidUtilities.dp(5)) { firstVisibleItem++; } else { break; } } scrollSlidingTabStrip .onPageScrolled(stickersGridAdapter.getTabForPosition(firstVisibleItem) + 1, 0); } }); } setBackgroundColor(0xfff5f6f7); pager = new ViewPager(context) { @Override public boolean onInterceptTouchEvent(MotionEvent ev) { if (getParent() != null) { getParent().requestDisallowInterceptTouchEvent(true); } return super.onInterceptTouchEvent(ev); } }; pager.setAdapter(new EmojiPagesAdapter()); pagerSlidingTabStripContainer = new LinearLayout(context) { @Override public boolean onInterceptTouchEvent(MotionEvent ev) { if (getParent() != null) { getParent().requestDisallowInterceptTouchEvent(true); } return super.onInterceptTouchEvent(ev); } }; pagerSlidingTabStripContainer.setOrientation(LinearLayout.HORIZONTAL); pagerSlidingTabStripContainer.setBackgroundColor(0xfff5f6f7); addView(pagerSlidingTabStripContainer, LayoutHelper.createFrame(LayoutParams.MATCH_PARENT, 48)); PagerSlidingTabStrip pagerSlidingTabStrip = new PagerSlidingTabStrip(context); pagerSlidingTabStrip.setViewPager(pager); pagerSlidingTabStrip.setShouldExpand(true); pagerSlidingTabStrip.setIndicatorHeight(AndroidUtilities.dp(2)); pagerSlidingTabStrip.setUnderlineHeight(AndroidUtilities.dp(1)); pagerSlidingTabStrip.setIndicatorColor(0xff2b96e2); pagerSlidingTabStrip.setUnderlineColor(0xffe2e5e7); pagerSlidingTabStripContainer.addView(pagerSlidingTabStrip, LayoutHelper.createLinear(0, 48, 1.0f)); pagerSlidingTabStrip.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { EmojiView.this.onPageScrolled(position, getMeasuredWidth(), positionOffsetPixels); } @Override public void onPageSelected(int position) { } @Override public void onPageScrollStateChanged(int state) { } }); FrameLayout frameLayout = new FrameLayout(context); pagerSlidingTabStripContainer.addView(frameLayout, LayoutHelper.createLinear(52, 48)); backspaceButton = new ImageView(context) { @Override public boolean onTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { backspacePressed = true; backspaceOnce = false; postBackspaceRunnable(350); } else if (event.getAction() == MotionEvent.ACTION_CANCEL || event.getAction() == MotionEvent.ACTION_UP) { backspacePressed = false; if (!backspaceOnce) { if (EmojiView.this.listener != null && EmojiView.this.listener.onBackspace()) { backspaceButton.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP); } } } super.onTouchEvent(event); return true; } }; backspaceButton.setImageResource(R.drawable.ic_smiles_backspace); backspaceButton.setBackgroundResource(R.drawable.ic_emoji_backspace); backspaceButton.setScaleType(ImageView.ScaleType.CENTER); frameLayout.addView(backspaceButton, LayoutHelper.createFrame(52, 48)); View view = new View(context); view.setBackgroundColor(0xffe2e5e7); frameLayout.addView(view, LayoutHelper.createFrame(52, 1, Gravity.LEFT | Gravity.BOTTOM)); recentsWrap = new FrameLayout(context); recentsWrap.addView(views.get(0)); TextView textView = new TextView(context); textView.setText(LocaleController.getString("NoRecent", R.string.NoRecent)); textView.setTextSize(18); textView.setTextColor(0xff888888); textView.setGravity(Gravity.CENTER); recentsWrap.addView(textView); views.get(0).setEmptyView(textView); addView(pager, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 0, 48, 0, 0)); loadRecents(); if (Emoji.data[0] == null || Emoji.data[0].length == 0) { pager.setCurrentItem(1); } }
From source file:com.zhenlaidian.ui.InputCarNumberActivity.java
public void sheView3() { final GridView gv_police = (GridView) view3.findViewById(R.id.input_gridview_dialog); gv_police.setSelector(new ColorDrawable(Color.TRANSPARENT)); final String[] police = new String[] { "", "", "", "", "", "", "", "?", "", "?", "WJ", "", "", "", "", "", "", "", "", "", "" }; ArrayList<String> polices = new ArrayList<String>(); for (int i = 0; i < police.length; i++) { polices.add(police[i]);//w w w .j ava 2 s. c om } InputCarNumberGridAdapter adapter = new InputCarNumberGridAdapter(context, polices, false); gv_police.setAdapter(adapter); gv_police.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, final int position, long id) { final int index = et_carnumber.getSelectionStart(); final Editable editable = et_carnumber.getText(); editable.insert(index, police[position]); } }); }
From source file:com.zhenlaidian.ui.InputCarNumberActivity.java
public void setView2() { final GridView gv_number = (GridView) view2.findViewById(R.id.input_gridview_dialog); gv_number.setSelector(new ColorDrawable(Color.TRANSPARENT)); final String[] number = new String[] { "A", "B", "C", "D", "0", "5", "E", "F", "G", "H", "1", "6", "J", "K", "L", "M", "2", "7", "N", "P", "Q", "R", "3", "8", "S", "T", "U", "V", "4", "9", "W", "X", "Y", "Z" }; ArrayList<String> numbers = new ArrayList<String>(); for (int i = 0; i < number.length; i++) { numbers.add(number[i]);//from w w w . ja v a2s . c o m } InputCarNumberGridAdapter adapter = new InputCarNumberGridAdapter(context, numbers, true); gv_number.setAdapter(adapter); gv_number.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, final int position, long id) { final int index = et_carnumber.getSelectionStart(); final Editable editable = et_carnumber.getText(); editable.insert(index, number[position]); } }); }