List of usage examples for android.widget ImageView ImageView
public ImageView(Context context)
From source file:org.gots.seed.view.SeedWidgetTile.java
@SuppressWarnings("deprecation") private void setupView() { if (mSeed == null) return;/*from w w w . j a v a 2 s. co m*/ // int familyImageRessource = 0; // if (mSeed.getFamily() != null) // familyImageRessource = getResources().getIdentifier( // "org.gots:drawable/family_" + mSeed.getFamily().toLowerCase(), null, null); // // if (familyImageRessource != 0) // setBackgroundResource(familyImageRessource); // else { // int sdk = android.os.Build.VERSION.SDK_INT; // if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) { // setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.family_unknown)); // } else { // setBackground(mContext.getResources().getDrawable(R.drawable.family_unknown)); // } // } SeedWidget seedWidget = (SeedWidget) findViewById(R.id.idSeedWidget2); seedWidget.setSeed(mSeed); TextView seedSpecie = (TextView) findViewById(R.id.IdSeedSpecie); seedSpecie.setText(SeedUtil.translateSpecie(mContext, mSeed)); if (GotsPreferences.DEBUG) seedSpecie.setText("(" + mSeed.getSeedId() + ")" + SeedUtil.translateSpecie(mContext, mSeed)); TextView seedVariety = (TextView) findViewById(R.id.IdSeedVariety); seedVariety.setText(mSeed.getVariety()); state = (ImageView) findViewById(R.id.imageStateValidation); if ("approved".equals(mSeed.getState())) state.setVisibility(View.VISIBLE); else state.setVisibility(View.GONE); // PlanningWidget planningSow = (PlanningWidget) fidindViewById(R.id.IdSeedSowingPlanning); // planningSow.setAdapter(new PlanningSowAdapter(mSeed)); // // // PlanningWidget planningHarvest = (PlanningWidget) findViewById(R.id.IdSeedHarvestPlanning); // planningHarvest.setAdapter(new PlanningHarvestAdapter(mSeed)); LinearLayout stock = (LinearLayout) findViewById(R.id.idSeedStock); stock.removeAllViews(); for (int i = 0; i < mSeed.getNbSachet(); i++) { ImageView seedbag = new ImageView(mContext); seedbag.setImageDrawable(mContext.getResources().getDrawable(R.drawable.seed_bag)); // seedbag.setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.bg_planning_sow)); LayoutParams params = new LinearLayout.LayoutParams(30, 30); seedbag.setLayoutParams(params); stock.addView(seedbag, i); } if (mSeed.getLanguage() != null && !"".equals(mSeed.getLanguage())) { ImageView flag = (ImageView) findViewById(R.id.IdSeedLanguage); int flagRessource = getResources() .getIdentifier("org.gots:drawable/" + mSeed.getLanguage().toLowerCase(), null, null); flag.setImageResource(flagRessource); } likeCount = (TextView) findViewById(R.id.textSeedLike); like = (ImageView) findViewById(R.id.ImageSeedLike); displayLikeStatus(mSeed.getLikeStatus()); if (mSeed.getUUID() == null) like.setVisibility(View.GONE); like.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new AsyncTask<Void, Void, LikeStatus>() { GotsException exception = null; @Override protected LikeStatus doInBackground(Void... params) { GotsSeedManager manager = GotsSeedManager.getInstance().initIfNew(mContext); try { return manager.like(mSeed, mSeed.getLikeStatus().getUserLikeStatus() == 1); } catch (GotsException e) { exception = e; return null; } catch (Exception e) { Log.e(getClass().getName(), "" + e.getMessage(), e); return null; } } protected void onPostExecute(LikeStatus result) { if (result == null && exception != null) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(mContext); // set title alertDialogBuilder.setTitle(exception.getMessage()); alertDialogBuilder.setMessage(exception.getMessageDescription()).setCancelable(false) .setPositiveButton(mContext.getResources().getString(R.string.login_connect), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // Intent loginIntent = new Intent(mContext, LoginDialogFragment.class); // mContext.startActivity(loginIntent); LoginDialogFragment dialogFragment = new LoginDialogFragment(); dialogFragment.setStyle(DialogFragment.STYLE_NORMAL, R.style.CustomDialog); dialogFragment.show(((FragmentActivity) mContext) .getSupportFragmentManager(), ""); } }) .setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); return; } mSeed.setLikeStatus(result); displayLikeStatus(result); mContext.sendBroadcast(new Intent(BroadCastMessages.SEED_DISPLAYLIST)); }; }.execute(); } }); }
From source file:com.angelatech.yeyelive.view.PeriscopeLayout.java
public void addHeart() { ImageView imageView = new ImageView(getContext()); //?// w w w. j a va 2 s . co m imageView.setImageDrawable(drawables[random.nextInt(7)]); imageView.setLayoutParams(lp); addView(imageView); Animator set = getAnimator(imageView); set.addListener(new AnimEndListener(imageView)); set.start(); }
From source file:com.ravi.apps.android.newsbytes.DetailsActivity.java
/** * Creates the starting views required for the shared element transition. */// www. ja v a 2 s.c o m private void createTransitionStartViews(Bundle bundle) { // Create the view objects. mThumbnailView = new ImageView(this); mHeadlineView = new TextView(this); // Set the thumbnail view parameters. mThumbnailView.setX(bundle.getFloat(MainActivity.IMAGE_XPOS)); mThumbnailView.setY(bundle.getFloat(MainActivity.IMAGE_YPOS)); byte[] thumbnailByteStream = bundle.getByteArray(MainActivity.IMAGE); if (thumbnailByteStream != null && thumbnailByteStream.length != 0) { // Get the thumbnail bitmap from byte array. Bitmap thumbnailBitmap = BitmapFactory.decodeByteArray(thumbnailByteStream, 0, thumbnailByteStream.length); // Set the thumbnail bitmap into the image view. if (thumbnailBitmap != null) { mThumbnailView.setImageBitmap(thumbnailBitmap); mThumbnailView.setScaleType(ImageView.ScaleType.FIT_XY); } } // Set the thumbnail view parameters. mHeadlineView.setX(bundle.getFloat(MainActivity.TEXT_XPOS)); mHeadlineView.setY(bundle.getFloat(MainActivity.TEXT_YPOS)); mHeadlineView.setText(bundle.getString(MainActivity.TEXT)); }
From source file:com.happysanta.vkspy.Fragments.MainFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { context = getActivity();//from w w w .j ava2 s .c o m if (savedInstanceState != null && UberFunktion.loading) { ProgressDialog dialog = new ProgressDialog(context); dialog.setMessage(context.getString(R.string.durov_function_activating_message)); UberFunktion.putNewDialogWindow(dialog); dialog.show(); } View rootView = inflater.inflate(R.layout.fragment_main, null); View happySanta = inflater.inflate(R.layout.main_santa, null); TextView happySantaText = (TextView) happySanta.findViewById(R.id.happySantaText); happySantaText.setText(Html.fromHtml(context.getString(R.string.app_description))); TextView happySantaLink = (TextView) happySanta.findViewById(R.id.happySantaLink); happySantaLink.setText(Html.fromHtml("vk.com/<b>happysanta</b>")); happySantaLink.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://vk.com/happysanta")); startActivity(browserIntent); } }); happySanta.setOnClickListener(new View.OnClickListener() { int i = 1; @Override public void onClick(View v) { if (i < 10) i++; else { i = 0; File F = Logs.getFile(); Uri U = Uri.fromFile(F); Intent i = new Intent(Intent.ACTION_SEND); i.setType("text/plain"); i.putExtra(Intent.EXTRA_STREAM, U); startActivity(Intent.createChooser(i, "What should we do with logs?")); } } }); SharedPreferences longpollPreferences = context.getSharedPreferences("longpoll", Context.MODE_MULTI_PROCESS); boolean longpollStatus = longpollPreferences.getBoolean("status", true); /*Bitmap tile = BitmapFactory.decodeResource(context.getResources(), R.drawable.underline); BitmapDrawable tiledBitmapDrawable = new BitmapDrawable(context.getResources(), tile); tiledBitmapDrawable.setTileModeX(Shader.TileMode.REPEAT); //tiledBitmapDrawable.setTileModeY(Shader.TileMode.REPEAT); santaGroundView.setBackgroundDrawable(tiledBitmapDrawable); BitmapDrawable bitmap = new BitmapDrawable(BitmapFactory.decodeResource( getResources(), R.drawable.underline2)); bitmap.setTileModeX(Shader.TileMode.REPEAT); */ LinearLayout layout = (LinearLayout) happySanta.findViewById(R.id.line); Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); int width = display.getWidth(); // deprecated for (int i = 0; width % (341 * i + 1) < width; i++) { layout.addView(new ImageView(context) { { setImageResource(R.drawable.underline2); setLayoutParams(new ViewGroup.LayoutParams(341, Helper.convertToDp(4))); setScaleType(ScaleType.CENTER_CROP); } }); } ListView preferencesView = (ListView) rootView.findViewById(R.id.preference); preferencesView.addHeaderView(happySanta, null, false); ArrayList<PreferenceItem> preferences = new ArrayList<PreferenceItem>(); /* preferences.add(new PreferenceItem(getUberfunction(), getUberfunctionDescription()) { @Override public void onClick() { if(UberFunktion.loading) { ProgressDialog dialog = new ProgressDialog(context); dialog.setMessage(context.getString(R.string.durov_function_activating_message)); UberFunktion.putNewDialogWindow(dialog); dialog.show(); return; } AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); final AlertDialog selector; View durov = getActivity().getLayoutInflater().inflate(R.layout.durov, null); SharedPreferences durovPreferences = context.getSharedPreferences("durov", Context.MODE_MULTI_PROCESS); boolean updateOnly = durovPreferences.getBoolean("loaded", false); if(updateOnly) ((TextView)durov.findViewById(R.id.description)).setText(R.string.durov_function_activated); if(Memory.users.getById(1)!=null && !updateOnly) { builder.setTitle(R.string.durov_joke_title); ((TextView)durov.findViewById(R.id.description)).setText(R.string.durov_joke_message); ( durov.findViewById(R.id.cat)).setVisibility(View.VISIBLE); builder.setNegativeButton(R.string.durov_joke_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { BugSenseHandler.sendEvent("? ? "); } }); BugSenseHandler.sendEvent("DUROV FRIEND CATCHED!!1"); }else{ builder.setTitle(R.string.durov_start_title); ( durov.findViewById(R.id.photo)).setVisibility(View.VISIBLE); ImageLoader.getInstance().displayImage("http://cs9591.vk.me/v9591001/70/VPSmUR954fQ.jpg",(ImageView) durov.findViewById(R.id.photo)); builder. setPositiveButton(updateOnly ? R.string.durov_start_update : R.string.durov_start_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { BugSenseHandler.sendEvent(" "); ProgressDialog uberfunctionDialog = ProgressDialog.show(getActivity(), context.getString(R.string.durov_function_activating_title), context.getString(R.string.durov_function_activating_message), true, false); UberFunktion.initialize(uberfunctionDialog); } }); builder.setNegativeButton(R.string.durov_start_cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { try { Intent browserIntent = new Intent( Intent.ACTION_VIEW, Uri.parse("https://vk.com/id1") ); startActivity(browserIntent); }catch(Exception exp){ AlertDialog.Builder errorShower = new AlertDialog.Builder(getActivity()); if (exp instanceof ActivityNotFoundException) { errorShower.setTitle(R.string.error); errorShower.setMessage(R.string.no_browser); } else { errorShower.setTitle(R.string.error); errorShower.setMessage(R.string.unknown_error); } errorShower.show(); } BugSenseHandler.sendEvent("? ? "); } }); } builder.setView(durov); selector = builder.create(); selector.show(); } }); */ preferences.add(new ToggleablePreferenceItem(getEnableSpy(), null, longpollStatus) { @Override public void onToggle(Boolean isChecked) { longpollToggle(isChecked); } }); preferences.add(new PreferenceItem(getAdvancedSettings()) { @Override public void onClick() { startActivity(new Intent(context, SettingsActivity.class)); } }); preferences.add(new PreferenceItem(getAbout()) { @Override public void onClick() { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); final AlertDialog aboutDialog; builder.setTitle(R.string.app_about).setCancelable(true) .setPositiveButton(R.string.app_about_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); View aboutView = getActivity().getLayoutInflater().inflate(R.layout.about, null); TextView aboutDescription = (TextView) aboutView.findViewById(R.id.description); aboutDescription.setText(Html.fromHtml(getResources().getString(R.string.app_about_description))); aboutDescription.setMovementMethod(LinkMovementMethod.getInstance()); aboutView.findViewById(R.id.license).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent browserIntent = new Intent(context, InfoActivity.class); startActivity(browserIntent); } }); builder.setView(aboutView); aboutDialog = builder.create(); aboutDialog.setCanceledOnTouchOutside(true); aboutDialog.show(); } }); preferencesView.setAdapter(new PreferenceAdapter(context, preferences)); return rootView; }
From source file:com.yahala.ui.Views.EmojiView.java
private void init() { setOrientation(LinearLayout.VERTICAL); for (int i = 0; i < Emoji.data.length; i++) { GridView gridView = new GridView(getContext()); gridView.setColumnWidth(OSUtilities.dpf(45.0f)); gridView.setNumColumns(-1);/*w w w .ja v a 2s . c om*/ views.add(gridView); EmojiGridAdapter localEmojiGridAdapter = new EmojiGridAdapter(Emoji.data[i]); gridView.setAdapter(localEmojiGridAdapter); adapters.add(localEmojiGridAdapter); } setBackgroundDrawable( new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[] { -14145496, -16777216 })); pager = new ViewPager(getContext()); pager.setAdapter(new EmojiPagesAdapter()); PagerSlidingTabStripEmoji tabs = new PagerSlidingTabStripEmoji(getContext()); tabs.setViewPager(pager); tabs.setShouldExpand(true); tabs.setIndicatorColor(0xff33b5e5); tabs.setIndicatorHeight(OSUtilities.dpf(2.0f)); tabs.setUnderlineHeight(OSUtilities.dpf(2.0f)); tabs.setUnderlineColor(1711276032); tabs.setTabBackground(0); LinearLayout localLinearLayout = new LinearLayout(getContext()); localLinearLayout.setOrientation(LinearLayout.HORIZONTAL); localLinearLayout.addView(tabs, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f)); ImageView localImageView = new ImageView(getContext()); localImageView.setImageResource(R.drawable.ic_emoji_backspace); localImageView.setScaleType(ImageView.ScaleType.CENTER_CROP); localImageView.setBackgroundResource(R.drawable.bg_emoji_bs); localImageView.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { if (EmojiView.this.listener != null) { EmojiView.this.listener.onBackspace(); } } }); localLinearLayout.addView(localImageView, new LinearLayout.LayoutParams(OSUtilities.dpf(61.0f), LayoutParams.MATCH_PARENT)); recentsWrap = new FrameLayout(getContext()); recentsWrap.addView(views.get(0)); TextView localTextView = new TextView(getContext()); localTextView.setText(LocaleController.getString("NoRecent", R.string.NoRecent)); localTextView.setTextSize(18.0f); localTextView.setTextColor(-7829368); localTextView.setGravity(17); recentsWrap.addView(localTextView); views.get(0).setEmptyView(localTextView); addView(localLinearLayout, new LinearLayout.LayoutParams(-1, OSUtilities.dpf(48.0f))); addView(pager); loadRecents(); if (Emoji.data[0] == null || Emoji.data[0].length == 0) { pager.setCurrentItem(1); } }
From source file:com.mumu.pokemongogo.HeadService.java
private void initGamePanelViews() { mHeadIconList = new ArrayList<>(); // Head Icon//w ww . j a va 2 s . c o m HeadIconView headIcon = new HeadIconView(new ImageView(this), mWindowManager, 0, 0); headIcon.getImageView().setImageResource(R.mipmap.ic_launcher); headIcon.setOnTapListener(new HeadIconView.OnTapListener() { @Override public void onTap(View view) { configHeadIconShowing(HeadIconView.AUTO); } @Override public void onLongPress(View view) { showExitConfirmDialog(); } }); mHeadIconList.add(headIcon); // Message Text Icon HeadIconView msgText = new HeadIconView(new TextView(this), mWindowManager, 120, 13); msgText.getTextView().setText(""); msgText.getTextView().setTextColor(Color.BLACK); msgText.getView().setBackgroundColor(Color.WHITE); mHeadIconList.add(msgText); // Start Game Pad Icon HeadIconView startIcon = new HeadIconView(new ImageView(this), mWindowManager, 0, 75); startIcon.getImageView().setImageResource(R.drawable.ic_play); startIcon.setOnTapListener(new HeadIconView.OnTapListener() { @Override public void onTap(View view) { configFreeWalking(); } @Override public void onLongPress(View view) { } }); mHeadIconList.add(startIcon); // Home Icon HeadIconView homeIcon = new HeadIconView(new ImageView(this), mWindowManager, 80, 90); homeIcon.getImageView().setImageResource(R.drawable.ic_location_pin); homeIcon.setOnTapListener(new HeadIconView.OnTapListener() { @Override public void onTap(View view) { Log.d(TAG, "config map icon"); mFakeLocationManager.cancelAutoPilot(); configHeadIconShowing(HeadIconView.INVISIBLE); Intent mapIntent = new Intent(mContext, MapLocationViewer.class); mapIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(mapIntent); } @Override public void onLongPress(View view) { } }); mHeadIconList.add(homeIcon); // Incubator Icon HeadIconView incubatorIcon = new HeadIconView(new ImageView(this), mWindowManager, 150, 90); incubatorIcon.getImageView().setImageResource(R.drawable.ic_egg_disabled); incubatorIcon.setOnTapListener(new HeadIconView.OnTapListener() { @Override public void onTap(View view) { Log.d(TAG, "config auto incubating"); configAutoIncubating(); } @Override public void onLongPress(View view) { } }); mHeadIconList.add(incubatorIcon); // Speed control Icon HeadIconView speedIcon = new HeadIconView(new ImageView(this), mWindowManager, 220, 85); speedIcon.getImageView().setImageResource(R.drawable.ic_one); speedIcon.setOnTapListener(new HeadIconView.OnTapListener() { @Override public void onTap(View view) { Log.d(TAG, "config speed"); if (!mAutoIncubating) configSpeed(); else mMessageText = "You can't"; } @Override public void onLongPress(View view) { } }); mHeadIconList.add(speedIcon); // Share the same on move listener for moving in the same time HeadIconView.OnMoveListener moveListener = new HeadIconView.OnMoveListener() { @Override public void onMove(int initialX, int initialY, float initialTouchX, float initialTouchY, MotionEvent event) { for (HeadIconView icon : mHeadIconList) { icon.moveIconDefault(initialX, initialY, initialTouchX, initialTouchY, event); } } }; // Set all to add for (HeadIconView icon : mHeadIconList) { icon.addView(); icon.setOnMoveListener(moveListener); } // Set default visibility mHeadIconList.get(IDX_START_ICON).setVisibility(View.INVISIBLE); mHeadIconList.get(IDX_HOME_ICON).setVisibility(View.INVISIBLE); mHeadIconList.get(IDX_INCUBATOR_ICON).setVisibility(View.INVISIBLE); mHeadIconList.get(IDX_SPEED_ICON).setVisibility(View.INVISIBLE); }
From source file:org.mareatlantica.ui.Views.EmojiView.java
private void init() { setOrientation(LinearLayout.VERTICAL); for (int i = 0; i < Emoji.data.length; i++) { GridView gridView = new GridView(getContext()); gridView.setColumnWidth(AndroidUtilities.dpf(45.0f)); gridView.setNumColumns(-1);/*from www. ja v a 2s.c o m*/ views.add(gridView); EmojiGridAdapter localEmojiGridAdapter = new EmojiGridAdapter(Emoji.data[i]); gridView.setAdapter(localEmojiGridAdapter); adapters.add(localEmojiGridAdapter); } setBackgroundDrawable( new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[] { -14145496, -16777216 })); pager = new ViewPager(getContext()); pager.setAdapter(new EmojiPagesAdapter()); PagerSlidingTabStrip tabs = new PagerSlidingTabStrip(getContext()); tabs.setViewPager(pager); tabs.setShouldExpand(true); tabs.setIndicatorColor(0xff33b5e5); tabs.setIndicatorHeight(AndroidUtilities.dpf(2.0f)); tabs.setUnderlineHeight(AndroidUtilities.dpf(2.0f)); tabs.setUnderlineColor(1711276032); tabs.setTabBackground(0); LinearLayout localLinearLayout = new LinearLayout(getContext()); localLinearLayout.setOrientation(LinearLayout.HORIZONTAL); localLinearLayout.addView(tabs, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f)); ImageView localImageView = new ImageView(getContext()); localImageView.setImageResource(R.drawable.ic_emoji_backspace); localImageView.setScaleType(ImageView.ScaleType.CENTER); localImageView.setBackgroundResource(R.drawable.bg_emoji_bs); localImageView.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { if (EmojiView.this.listener != null) { EmojiView.this.listener.onBackspace(); } } }); localLinearLayout.addView(localImageView, new LinearLayout.LayoutParams(AndroidUtilities.dpf(61.0f), LayoutParams.MATCH_PARENT)); recentsWrap = new FrameLayout(getContext()); recentsWrap.addView(views.get(0)); TextView localTextView = new TextView(getContext()); localTextView.setText(LocaleController.getString("NoRecent", R.string.NoRecent)); localTextView.setTextSize(18.0f); localTextView.setTextColor(-7829368); localTextView.setGravity(17); recentsWrap.addView(localTextView); views.get(0).setEmptyView(localTextView); addView(localLinearLayout, new LinearLayout.LayoutParams(-1, AndroidUtilities.dpf(48.0f))); addView(pager); loadRecents(); if (Emoji.data[0] == null || Emoji.data[0].length == 0) { pager.setCurrentItem(1); } }
From source file:com.b44t.ui.Components.PagerSlidingTabStrip.java
private void addIconTab(final int position, int resId) { ImageView tab = new ImageView(getContext()); tab.setFocusable(true);//w w w.j a v a 2 s. co m tab.setImageResource(resId); tab.setScaleType(ImageView.ScaleType.CENTER); tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pager.setCurrentItem(position); } }); tabsContainer.addView(tab); tab.setSelected(position == currentPosition); }
From source file:com.negaheno.ui.Components.EmojiView.java
private void init() { setOrientation(LinearLayout.VERTICAL); for (int i = 0; i < Emoji.data.length; i++) { GridView gridView = new GridView(getContext()); if (AndroidUtilities.isTablet()) { gridView.setColumnWidth(AndroidUtilities.dp(60)); } else {//ww w . j av a 2 s . co m gridView.setColumnWidth(AndroidUtilities.dp(45)); } gridView.setNumColumns(-1); views.add(gridView); EmojiGridAdapter localEmojiGridAdapter = new EmojiGridAdapter(Emoji.data[i]); gridView.setAdapter(localEmojiGridAdapter); AndroidUtilities.setListViewEdgeEffectColor(gridView, 0xff999999); adapters.add(localEmojiGridAdapter); } setBackgroundColor(0xff222222); pager = new ViewPager(getContext()); pager.setAdapter(new EmojiPagesAdapter()); PagerSlidingTabStrip tabs = new PagerSlidingTabStrip(getContext()); tabs.setViewPager(pager); tabs.setShouldExpand(true); tabs.setIndicatorColor(0xff33b5e5); tabs.setIndicatorHeight(AndroidUtilities.dp(2.0f)); tabs.setUnderlineHeight(AndroidUtilities.dp(2.0f)); tabs.setUnderlineColor(0x66000000); tabs.setTabBackground(0); LinearLayout localLinearLayout = new LinearLayout(getContext()); localLinearLayout.setOrientation(LinearLayout.HORIZONTAL); localLinearLayout.addView(tabs, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f)); ImageView localImageView = new ImageView(getContext()); localImageView.setImageResource(R.drawable.ic_emoji_backspace); localImageView.setScaleType(ImageView.ScaleType.CENTER); localImageView.setBackgroundResource(R.drawable.bg_emoji_bs); localImageView.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { if (EmojiView.this.listener != null) { EmojiView.this.listener.onBackspace(); } } }); localLinearLayout.addView(localImageView, new LinearLayout.LayoutParams(AndroidUtilities.dp(61), LayoutParams.MATCH_PARENT)); recentsWrap = new FrameLayout(getContext()); recentsWrap.addView(views.get(0)); TextView localTextView = new TextView(getContext()); localTextView.setText(LocaleController.getString("NoRecent", R.string.NoRecent)); localTextView.setTextSize(18.0f); localTextView.setTextColor(-7829368); localTextView.setGravity(17); recentsWrap.addView(localTextView); views.get(0).setEmptyView(localTextView); addView(localLinearLayout, new LinearLayout.LayoutParams(-1, AndroidUtilities.dp(48.0f))); addView(pager); loadRecents(); if (Emoji.data[0] == null || Emoji.data[0].length == 0) { pager.setCurrentItem(1); } updateColors(tabs); }
From source file:net.potterpcs.recipebook.RecipeViewer.java
@SuppressWarnings("deprecation") @Override//from w w w. j av a 2 s . c o m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.recipeviewer); app = (RecipeBook) getApplication(); data = app.getData(); preferences = PreferenceManager.getDefaultSharedPreferences(this); photoPref = preferences.getBoolean(getResources().getString(R.string.prefphotokey), true); dirPhotoPref = preferences.getBoolean(getResources().getString(R.string.prefdirphotokey), true); // Fill in the UI rvname = (TextView) findViewById(R.id.rvname); rvcreator = (TextView) findViewById(R.id.rvcreator); rvserving = (TextView) findViewById(R.id.rvserving); rvtime = (TextView) findViewById(R.id.rvtime); rvrating = (RatingBar) findViewById(R.id.rvrating); lvingredients = (GridView) findViewById(R.id.ingredients); lvdirections = (ListView) findViewById(R.id.directions); rid = Long.parseLong(getIntent().getData().getLastPathSegment()); RecipeData.Recipe r = data.getSingleRecipeObject(rid); rvname.setText(r.name); rvcreator.setText(r.creator); rvserving.setText(Integer.toString(r.serving)); rvtime.setText(DateUtils.formatElapsedTime(r.time)); rvrating.setRating(r.rating); photoUri = r.photo; if (photoPref && photoUri != null && !photoUri.equals("")) { rvphoto = (FrameLayout) findViewById(R.id.photofragment); ImageView iv = new ImageView(this); setOrDownloadImage(iv, photoUri); iv.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); PhotoDialog pd = PhotoDialog.newInstance(photoUri); pd.show(ft, "dialog"); } }); rvphoto.addView(iv); } directionsAdapter = new SimpleCursorAdapter(this, R.layout.recipedirectionrow, null, DIRECTIONS_FIELDS, DIRECTIONS_IDS, 0); directionsAdapter.setViewBinder(new DirectionViewBinder(this)); lvdirections.setAdapter(directionsAdapter); lvdirections.setDividerHeight(0); ingredientsAdapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1, null, INGREDIENTS_FIELDS, INGREDIENTS_IDS, 0); lvingredients.setAdapter(ingredientsAdapter); // Set up sharing intent shareIntent = ShareCompat.IntentBuilder.from(this).setSubject(r.name).setText(r.toText(this)) .setType("text/plain"); }