List of usage examples for android.widget ImageView ImageView
public ImageView(Context context)
From source file:com.microsoft.mimickeralarm.ringing.ShareFragment.java
private static void drawStamp(Context context, Bitmap bitmap, String question) { Canvas canvas = new Canvas(bitmap); canvas.drawBitmap(bitmap, 0, 0, null); float opacity = 0.7f; int horizontalPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, context.getResources().getDisplayMetrics()); int verticalPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, context.getResources().getDisplayMetrics()); int textSize = 16; // defined in SP int height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 16, context.getResources().getDisplayMetrics()); LinearLayout layout = new LinearLayout(context); layout.setOrientation(LinearLayout.HORIZONTAL); layout.setBackgroundResource(R.drawable.rounded_corners); layout.getBackground().setAlpha((int) (opacity * 255)); layout.setPadding(horizontalPadding, verticalPadding, horizontalPadding, verticalPadding); ImageView logo = new ImageView(context); logo.setImageDrawable(ContextCompat.getDrawable(context, R.mipmap.ic_launcher_no_bg)); layout.addView(logo);/*from ww w.ja va2 s . com*/ TextView textView = new TextView(context); textView.setVisibility(View.VISIBLE); if (question != null) { textView.setText(question); } else { textView.setText("Mimicker"); } textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, textSize); textView.setPadding(horizontalPadding, 0, 0, 0); LinearLayout.LayoutParams centerInParent = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); centerInParent.gravity = Gravity.CENTER_VERTICAL; layout.addView(textView, centerInParent); layout.measure(canvas.getWidth(), height); layout.layout(0, 0, layout.getMeasuredWidth(), layout.getMeasuredHeight()); canvas.translate(horizontalPadding, (float) (canvas.getHeight() * 0.8 - height)); float scale = Math.min(1.0f, canvas.getWidth() / 1080f); canvas.scale(scale, scale); layout.draw(canvas); }
From source file:com.google.android.gcm.demo.ui.MainActivity.java
@Override protected void onCreate(Bundle savedState) { super.onCreate(savedState); setContentView(R.layout.activity_main); mLogger = new Logger(this); mLogsUI = (TextView) findViewById(R.id.logs); mLoggerCallback = new BroadcastReceiver() { @Override//from w w w.j a v a 2 s . c o m public void onReceive(Context context, Intent intent) { switch (intent.getAction()) { case LoggingService.ACTION_CLEAR_LOGS: mLogsUI.setText(""); break; case LoggingService.ACTION_LOG: StringBuilder stringBuilder = new StringBuilder(); String newLog = intent.getStringExtra(LoggingService.EXTRA_LOG_MESSAGE); String oldLogs = Html.toHtml(new SpannableString(mLogsUI.getText())); appendFormattedLogLine(newLog, stringBuilder); stringBuilder.append(oldLogs); mLogsUI.setText(Html.fromHtml(stringBuilder.toString())); List<Fragment> fragments = getSupportFragmentManager().getFragments(); for (Fragment fragment : fragments) { if (fragment instanceof RefreshableFragment && fragment.isVisible()) { ((RefreshableFragment) fragment).refresh(); } } break; } } }; Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerView = (FrameLayout) findViewById(R.id.navigation_drawer); mDrawerMenu = (ListView) findViewById(R.id.navigation_drawer_menu); mDrawerScrim = findViewById(R.id.navigation_drawer_scrim); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); TypedArray colorPrimaryDark = getTheme().obtainStyledAttributes(new int[] { R.attr.colorPrimaryDark }); mDrawerLayout.setStatusBarBackgroundColor(colorPrimaryDark.getColor(0, 0xFF000000)); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); colorPrimaryDark.recycle(); ImageView drawerHeader = new ImageView(this); drawerHeader.setImageResource(R.drawable.drawer_gcm_logo); mDrawerMenu.addHeaderView(drawerHeader); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // Set the drawer width accordingly with the guidelines: window_width - toolbar_height. toolbar.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { @Override public void onLayoutChange(View view, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { if (left == 0 && top == 0 && right == 0 && bottom == 0) { return; } DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); float logicalDensity = metrics.density; int maxWidth = (int) Math.ceil(320 * logicalDensity); DrawerLayout.LayoutParams params = (DrawerLayout.LayoutParams) mDrawerView.getLayoutParams(); int newWidth = view.getWidth() - view.getHeight(); params.width = (newWidth > maxWidth ? maxWidth : newWidth); mDrawerView.setLayoutParams(params); } }); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) { mDrawerView.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() { @TargetApi(Build.VERSION_CODES.KITKAT_WATCH) @Override public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) { // Set scrim height to match status bar height. mDrawerScrim.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, insets.getSystemWindowInsetTop())); return insets; } }); } int activeItemIndicator = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) ? android.R.layout.simple_list_item_activated_1 : android.R.layout.simple_list_item_checked; mMainMenu = new MainMenu(this); mDrawerMenu.setOnItemClickListener(this); mDrawerMenu.setAdapter(new ArrayAdapter<>(getSupportActionBar().getThemedContext(), activeItemIndicator, android.R.id.text1, mMainMenu.getEntries())); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open, R.string.drawer_close) { @Override public void onDrawerOpened(View drawerView) { // The user learned how to open the drawer. Do not open it for him anymore. getAppPreferences().edit().putBoolean(PREF_OPEN_DRAWER_AT_STARTUP, false).apply(); super.onDrawerOpened(drawerView); } }; boolean activityResumed = (savedState != null); boolean openDrawer = getAppPreferences().getBoolean(PREF_OPEN_DRAWER_AT_STARTUP, true); int lastScreenId = getAppPreferences().getInt(PREF_LAST_SCREEN_ID, 0); selectItem(lastScreenId); if (!activityResumed && openDrawer) { mDrawerLayout.openDrawer(mDrawerView); } mDrawerLayout.setDrawerListener(mDrawerToggle); /* * Here we check if the Activity was created by the user clicking on one of our GCM * notifications: * 1. Check if the action of the intent used to launch the Activity. * 2. Print out any additional data sent with the notification. This is included as extras * on the intent. */ Intent launchIntent = getIntent(); if ("gcm_test_app_notification_click_action".equals(launchIntent.getAction())) { Bundle data = launchIntent.getExtras(); data.isEmpty(); // Force the bundle to unparcel so that toString() works String format = getResources().getString(R.string.notification_intent_received); mLogger.log(Log.INFO, String.format(format, data)); } }
From source file:com.pikachu.emoji.widget.EmojiView.java
/** * ?</br>/* w ww. j a v a 2 s.c om*/ * * @return */ private ImageView createIndicator() { ImageView imageView = new ImageView(getContext()); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(30, 30); params.gravity = Gravity.CENTER; imageView.setLayoutParams(params); imageView.setImageDrawable(ResFinder.getDrawable(mNormalIcon)); imageView.setPadding(0, 0, 10, 0); return imageView; }
From source file:de.skubware.opentraining.activity.create_workout.ExerciseTypeDetailFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_exercisetype_detail, container, false); ViewGroup rootLayout = (ViewGroup) rootView.findViewById(R.id.fragment_exercisetype_detail_layout); // If Image Exists if (!mExercise.getImagePaths().isEmpty()) { // Create Image View ImageView imageView = new ImageView(rootView.getContext()); imageView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); imageView.setPadding(20, 20, 20, 20); rootLayout.addView(imageView);/*from w w w . ja va 2 s . c o m*/ imageView.setVisibility(View.VISIBLE); // set gesture detector this.mGestureScanner = new GestureDetector(this.getActivity(), new ExerciseDetailOnGestureListener(this, imageView, mExercise)); //Set Image DataHelper data = new DataHelper(getActivity()); imageView.setImageDrawable(data.getDrawable(mExercise.getImagePaths().get(0).toString())); rootView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return mGestureScanner.onTouchEvent(event); } }); } else { TextView textView = new TextView(rootView.getContext()); textView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); textView.setGravity(Gravity.CENTER); textView.setPadding(10, 10, 10, 10); textView.setText(Html.fromHtml(mExercise.getDescription())); rootLayout.addView(textView); } return rootView; }
From source file:com.xiaoya.framepager.SuperAwesomeCardFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { System.out.println(position + "======>>>>>"); View v = inflater.inflate(R.layout.fragment_setting, container, false); FrameLayout fram_gallery = (FrameLayout) v.findViewById(R.id.frame_gallery); fram_gallery.setVisibility(View.GONE); ListView lv_news = (ListView) v.findViewById(R.id.lv_news); System.out.println("position ====>>>>>>" + position); if (position == 0) { fram_gallery.setVisibility(View.VISIBLE); images_ga = (AdImageGallery) v.findViewById(R.id.image_wall_gallery); images_ga.setImageActivity(this); Bitmap image = BitmapFactory.decodeResource(getResources(), R.drawable.gallary_moren); imagesCache.put("background_non_load", image); // linear_point = (LinearLayout) v.findViewById(R.id.gallery_point_linear); urls = new ArrayList<String>(); // List urls.add("http://f11.topit.me/l/201009/16/12845672546160.jpg"); urls.add("http://f12.topit.me/l166/101665601956b260eb.jpg"); urls.add("http://i6.topit.me/6/15/50/1147943393d6950156l.jpg"); urls.add("http://f6.topit.me/6/08/22/113361531058822086l.jpg"); urls.add("http://i9.topit.me/9/23/10/1147966176c1910239l.jpg"); List<String> imageList = new ArrayList<String>(); imageList.add(""); imageList.add(""); imageList.add(""); imageList.add(""); imageList.add(""); ImageAdapter imageAdapter = new ImageAdapter(getActivity(), urls, imageList); images_ga.setAdapter(imageAdapter); images_ga.setOnItemClickListener(new OnItemClickListener() { @Override/*from w w w .j a va 2s . c o m*/ public void onItemClick(AdapterView<?> arg0, View arg1, int positioin, long arg3) { // TODO Auto-generated method stub Toast.makeText(getActivity(), ":" + positioin + ":....", Toast.LENGTH_SHORT).show(); } }); // for (int i = 0; i < urls.size(); i++) { // TextView textView=new TextView(getActivity()); // textView.setText(imageList.get(i%urls.size())); // linear_point.addView(textView); // } for (int i = 0; i < urls.size(); i++) { ImageView pointView = new ImageView(getActivity()); if (i == 0) { pointView.setBackgroundResource(R.drawable.feature_point_cur); } else pointView.setBackgroundResource(R.drawable.feature_point); linear_point.addView(pointView); } } lv_news.setAdapter(new MyAdapter_news(getActivity(), list)); return v; }
From source file:com.umeng.comm.ui.emoji.EmojiBorad.java
/** * ?</br>/*from ww w. jav a 2s.c o m*/ * * @return */ private ImageView createIndicator() { ImageView imageView = new ImageView(getContext()); LayoutParams params = new LayoutParams(30, 30); params.gravity = Gravity.CENTER; imageView.setLayoutParams(params); imageView.setImageDrawable(ResFinder.getDrawable(mNormalIcon)); imageView.setPadding(0, 0, 10, 0); return imageView; }
From source file:com.ab.view.sliding.AbBottomTabView_fix.java
/** * Instantiates a new ab bottom tab view. * * @param context the context//from w w w.j a v a2 s . c o m * @param attrs the attrs */ public AbBottomTabView_fix(Context context, AttributeSet attrs) { super(context, attrs); this.context = context; this.setOrientation(LinearLayout.VERTICAL); this.setBackgroundColor(Color.rgb(255, 255, 255)); mTabLayout = new LinearLayout(context); mTabLayout.setOrientation(LinearLayout.HORIZONTAL); mTabLayout.setGravity(Gravity.CENTER); //View? mViewPager = new AbViewPager(context); //ViewPager,setId()id mViewPager.setId(1985); pagerItemList = new ArrayList<Fragment>(); this.addView(mViewPager, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 0, 1)); //? mTabImg = new ImageView(context); mTabImg.setBackgroundColor(tabSlidingColor); this.addView(mTabImg, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, tabSlidingHeight)); this.addView(mTabLayout, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); //Tab? tabItemList = new ArrayList<AbTabItemView>(); tabItemTextList = new ArrayList<String>(); tabItemDrawableList = new ArrayList<Drawable>(); //?FragmentActivity if (!(this.context instanceof FragmentActivity)) { AbLogUtil.e(AbBottomTabView_fix.class, "AbSlidingTabView?context,FragmentActivity"); } DisplayMetrics mDisplayMetrics = AbAppUtil.getDisplayMetrics(context); mWidth = mDisplayMetrics.widthPixels; FragmentManager mFragmentManager = ((FragmentActivity) this.context).getFragmentManager(); mFragmentPagerAdapter = new AbFragmentPagerStateAdapter(mFragmentManager, pagerItemList); mViewPager.setAdapter(mFragmentPagerAdapter); mViewPager.setOnPageChangeListener(new MyOnPageChangeListener()); mViewPager.setOffscreenPageLimit(3); }
From source file:com.b44t.ui.Components.PasscodeView.java
public PasscodeView(final Context context) { super(context); setWillNotDraw(false);/*from w w w .ja v a2s . c o m*/ setVisibility(GONE); backgroundFrameLayout = new FrameLayout(context); addView(backgroundFrameLayout); LayoutParams layoutParams = (LayoutParams) backgroundFrameLayout.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; backgroundFrameLayout.setLayoutParams(layoutParams); passwordFrameLayout = new FrameLayout(context); addView(passwordFrameLayout); layoutParams = (LayoutParams) passwordFrameLayout.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP | Gravity.LEFT; passwordFrameLayout.setLayoutParams(layoutParams); ImageView imageView = new ImageView(context); imageView.setScaleType(ImageView.ScaleType.FIT_XY); imageView.setImageResource(R.drawable.ic_launcher /* EDIT BY MR -- was: passcode_logo */); passwordFrameLayout.addView(imageView); layoutParams = (LayoutParams) imageView.getLayoutParams(); if (AndroidUtilities.density < 1) { layoutParams.width = AndroidUtilities.dp(30); layoutParams.height = AndroidUtilities.dp(30); } else { layoutParams.width = AndroidUtilities.dp(40); layoutParams.height = AndroidUtilities.dp(40); } layoutParams.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM; layoutParams.bottomMargin = AndroidUtilities.dp(100); imageView.setLayoutParams(layoutParams); passcodeTextView = new TextView(context); passcodeTextView.setTextColor(0xffffffff); passcodeTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); passcodeTextView.setGravity(Gravity.CENTER_HORIZONTAL); passwordFrameLayout.addView(passcodeTextView); layoutParams = (LayoutParams) passcodeTextView.getLayoutParams(); layoutParams.width = LayoutHelper.WRAP_CONTENT; layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.bottomMargin = AndroidUtilities.dp(62); layoutParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL; passcodeTextView.setLayoutParams(layoutParams); passwordEditText = new EditText(context); passwordEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 36); passwordEditText.setTextColor(0xffffffff); passwordEditText.setMaxLines(1); passwordEditText.setLines(1); passwordEditText.setGravity(Gravity.CENTER_HORIZONTAL); passwordEditText.setSingleLine(true); passwordEditText.setImeOptions(EditorInfo.IME_ACTION_DONE); passwordEditText.setTypeface(Typeface.DEFAULT); passwordEditText.setBackgroundDrawable(null); AndroidUtilities.clearCursorDrawable(passwordEditText); passwordFrameLayout.addView(passwordEditText); layoutParams = (FrameLayout.LayoutParams) passwordEditText.getLayoutParams(); layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.leftMargin = AndroidUtilities.dp(70); layoutParams.rightMargin = AndroidUtilities.dp(70); layoutParams.bottomMargin = AndroidUtilities.dp(6); layoutParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL; passwordEditText.setLayoutParams(layoutParams); passwordEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { if (i == EditorInfo.IME_ACTION_DONE) { processDone(false); return true; } return false; } }); passwordEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { if (passwordEditText.length() == 4 && UserConfig.passcodeType == 0) { processDone(false); } } }); passwordEditText.setCustomSelectionActionModeCallback(new ActionMode.Callback() { public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } public void onDestroyActionMode(ActionMode mode) { } public boolean onCreateActionMode(ActionMode mode, Menu menu) { return false; } public boolean onActionItemClicked(ActionMode mode, MenuItem item) { return false; } }); checkImage = new ImageView(context); checkImage.setImageResource(R.drawable.passcode_check); checkImage.setScaleType(ImageView.ScaleType.CENTER); checkImage.setBackgroundResource(R.drawable.bar_selector_lock); passwordFrameLayout.addView(checkImage); layoutParams = (LayoutParams) checkImage.getLayoutParams(); layoutParams.width = AndroidUtilities.dp(60); layoutParams.height = AndroidUtilities.dp(60); layoutParams.bottomMargin = AndroidUtilities.dp(4); layoutParams.rightMargin = AndroidUtilities.dp(10); layoutParams.gravity = Gravity.BOTTOM | Gravity.RIGHT; checkImage.setLayoutParams(layoutParams); checkImage.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { processDone(false); } }); FrameLayout lineFrameLayout = new FrameLayout(context); lineFrameLayout.setBackgroundColor(0x26ffffff); passwordFrameLayout.addView(lineFrameLayout); layoutParams = (LayoutParams) lineFrameLayout.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = AndroidUtilities.dp(1); layoutParams.gravity = Gravity.BOTTOM | Gravity.LEFT; layoutParams.leftMargin = AndroidUtilities.dp(20); layoutParams.rightMargin = AndroidUtilities.dp(20); lineFrameLayout.setLayoutParams(layoutParams); numbersFrameLayout = new FrameLayout(context); addView(numbersFrameLayout); layoutParams = (LayoutParams) numbersFrameLayout.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP | Gravity.LEFT; numbersFrameLayout.setLayoutParams(layoutParams); lettersTextViews = new ArrayList<>(10); numberTextViews = new ArrayList<>(10); numberFrameLayouts = new ArrayList<>(10); for (int a = 0; a < 10; a++) { TextView textView = new TextView(context); textView.setTextColor(0xffffffff); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 36); textView.setGravity(Gravity.CENTER); textView.setText(String.format(Locale.US, "%d", a)); numbersFrameLayout.addView(textView); layoutParams = (LayoutParams) textView.getLayoutParams(); layoutParams.width = AndroidUtilities.dp(50); layoutParams.height = AndroidUtilities.dp(50); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; textView.setLayoutParams(layoutParams); numberTextViews.add(textView); textView = new TextView(context); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12); textView.setTextColor(0x7fffffff); textView.setGravity(Gravity.CENTER); numbersFrameLayout.addView(textView); layoutParams = (LayoutParams) textView.getLayoutParams(); layoutParams.width = AndroidUtilities.dp(50); layoutParams.height = AndroidUtilities.dp(20); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; textView.setLayoutParams(layoutParams); switch (a) { case 0: textView.setText("+"); break; case 2: textView.setText("ABC"); break; case 3: textView.setText("DEF"); break; case 4: textView.setText("GHI"); break; case 5: textView.setText("JKL"); break; case 6: textView.setText("MNO"); break; case 7: textView.setText("PQRS"); break; case 8: textView.setText("TUV"); break; case 9: textView.setText("WXYZ"); break; default: break; } lettersTextViews.add(textView); } eraseView = new ImageView(context); eraseView.setScaleType(ImageView.ScaleType.CENTER); eraseView.setImageResource(R.drawable.passcode_delete); numbersFrameLayout.addView(eraseView); layoutParams = (LayoutParams) eraseView.getLayoutParams(); layoutParams.width = AndroidUtilities.dp(50); layoutParams.height = AndroidUtilities.dp(50); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; eraseView.setLayoutParams(layoutParams); for (int a = 0; a < 11; a++) { FrameLayout frameLayout = new FrameLayout(context); frameLayout.setBackgroundResource(R.drawable.bar_selector_lock); frameLayout.setTag(a); if (a == 10) { frameLayout.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { passwordEditText.setText(""); return true; } }); } frameLayout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { int tag = (Integer) v.getTag(); switch (tag) { case 0: appendCharacter("0"); break; case 1: appendCharacter("1"); break; case 2: appendCharacter("2"); break; case 3: appendCharacter("3"); break; case 4: appendCharacter("4"); break; case 5: appendCharacter("5"); break; case 6: appendCharacter("6"); break; case 7: appendCharacter("7"); break; case 8: appendCharacter("8"); break; case 9: appendCharacter("9"); break; case 10: String text = passwordEditText.getText().toString(); if (text.length() > 0) { passwordEditText.setText(text.substring(0, text.length() - 1)); } break; } if (passwordEditText.getText().toString().length() == 4) { processDone(false); } } }); numberFrameLayouts.add(frameLayout); } for (int a = 10; a >= 0; a--) { FrameLayout frameLayout = numberFrameLayouts.get(a); numbersFrameLayout.addView(frameLayout); layoutParams = (LayoutParams) frameLayout.getLayoutParams(); layoutParams.width = AndroidUtilities.dp(100); layoutParams.height = AndroidUtilities.dp(100); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; frameLayout.setLayoutParams(layoutParams); } }
From source file:org.digitalcampus.oppia.widgets.ResourceWidget.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); LinearLayout ll = (LinearLayout) getView().findViewById(R.id.widget_resource_object); String fileUrl = course.getLocation() + activity .getLocation(prefs.getString(PrefsActivity.PREF_LANGUAGE, Locale.getDefault().getLanguage())); // show description if any String desc = activity//w w w.ja v a 2 s .c o m .getDescription(prefs.getString(PrefsActivity.PREF_LANGUAGE, Locale.getDefault().getLanguage())); TextView descTV = (TextView) getView().findViewById(R.id.widget_resource_description); if (desc.length() > 0) { descTV.setText(desc); } else { descTV.setVisibility(View.GONE); } File file = new File(fileUrl); setResourceFileName(file.getName()); OnResourceClickListener orcl = new OnResourceClickListener(super.getActivity(), activity.getMimeType()); // show image files if (activity.getMimeType().equals("image/jpeg") || activity.getMimeType().equals("image/png")) { ImageView iv = new ImageView(super.getActivity()); Bitmap myBitmap = BitmapFactory.decodeFile(fileUrl); iv.setImageBitmap(myBitmap); LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); ll.addView(iv, lp); iv.setTag(file); iv.setOnClickListener(orcl); } else { // add button to open other filetypes in whatever app the user has installed as default for that filetype Button btn = new Button(super.getActivity()); btn.setText(super.getActivity().getString(R.string.widget_resource_open_file, file.getName())); btn.setTextAppearance(super.getActivity(), R.style.ButtonText); ll.addView(btn); btn.setTag(file); btn.setOnClickListener(orcl); } }
From source file:org.borderstone.tagtags.TTStartActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setTheme(R.style.AppTheme); this.setContentView(R.layout.activity_start); Toolbar toolbar = (Toolbar) this.findViewById(R.id.toolbar); //toolbar.inflateMenu(R.menu.menu_start); toolbar.setTitle("TagTags"); toolbar.setVisibility(View.VISIBLE); TTStartActivity.me = getApplicationContext(); protocol.setAction("android.intent.action.PROTOCOL"); settings.setAction("android.intent.action.SETTINGS"); Constants.init(new File(this.getFilesDir(), "bsettings.txt"), this.getApplicationContext()); Constants.fileListener = this; /*Load variables that are stored in a text file keeping version info and info about third party resources here, for easy editing*/ try {/*from w w w . j av a 2 s .co m*/ BufferedReader reader = new BufferedReader( new InputStreamReader(this.getResources().openRawResource(R.raw.appinfo))); String line = reader.readLine(); String[] t; while (line != null) { t = line.split(":"); if (line.startsWith("#thirdparty:")) thirdparty += t[1] + "\n"; else if (line.startsWith("#recentchanges:")) recentchanges += "-- " + t[1] + "\n"; line = reader.readLine(); } //just to remove the final new line. if (!thirdparty.equals("")) thirdparty = thirdparty.substring(0, thirdparty.length() - 1); if (!recentchanges.equals("")) recentchanges = recentchanges.substring(0, recentchanges.length() - 1); } catch (Exception ignored) { } //Most of the code below is purely for aesthetics! txtPhilosophy = new BTitleLabel(this); txtPhilosophy.setTypeface(Typeface.DEFAULT_BOLD); txtPhilosophy.setLayoutParams(Constants.defaultParams); txtPhilosophy.setOnClickListener(this); txtPhilosophy.setTextColor(Color.BLACK); txtVersion = new BStandardLabel(this); txtVersion.setText("Recent changes:\n" + recentchanges); txtVersion.setLayoutParams(Constants.defaultParams); txtVersion.setTextColor(Color.BLACK); try { PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0); toolbar.setSubtitle("v. " + pInfo.versionName); } catch (PackageManager.NameNotFoundException ignored) { } toolbar.setNavigationIcon(R.drawable.drawer); ImageView slu = new ImageView(this); ImageView sites = new ImageView(this); slu.setImageResource(R.drawable.slulogo); sites.setImageResource(R.drawable.sites); LinearLayout llLogos = new LinearLayout(this); llLogos.setOrientation(LinearLayout.HORIZONTAL); llLogos.setGravity(Gravity.END | Gravity.CENTER_VERTICAL); llLogos.addView(slu); llLogos.addView(sites); setPhiloText(); LinearLayout back = (LinearLayout) this.findViewById(R.id.back); back.setOrientation(LinearLayout.VERTICAL); txtPhilosophy.setLayoutParams(Constants.defaultParams); txtPhilosophy.setBackgroundResource(R.drawable.border); txtVersion.setLayoutParams(Constants.defaultParams); txtVersion.setBackgroundResource(R.drawable.border_recurring); back.addView(txtPhilosophy); back.addView(txtVersion); back.addView(llLogos); lblSettings = new BButton(this); lblDownload = new BButton(this); lblDownload.setIcon(R.drawable.download); lblSettings.setIcon(R.drawable.settings); lblSettings.setText("Settings"); lblDownload.setText("Download from server"); lblSettings.setOnClickListener(this); lblDownload.setOnClickListener(this); if (!checkPermissions()) { final Intent intro = new Intent(); intro.setAction("android.intent.action.INTRO"); this.startActivity(intro); } BTitleLabel lblProperties = new BTitleLabel(this); BTitleLabel lblLocal = new BTitleLabel(this); fileNavView = new BFileNavView(this, this); lblProperties.setTextSize(Constants.fontSize + 2); lblLocal.setTextSize(Constants.fontSize + 2); lblProperties.setText("PROPERTIES"); lblProperties.setTextColor(Color.WHITE); lblProperties.setGravity(Gravity.CENTER); lblLocal.setText("LOCAL FILES"); lblLocal.setTextColor(Color.WHITE); lblLocal.setGravity(Gravity.CENTER); final DrawerLayout drawerLayout = (DrawerLayout) this.findViewById(R.id.startDrawerLayout); final LinearLayout drawer = (LinearLayout) this.findViewById(R.id.drawer); drawer.setClickable(false); drawer.bringToFront(); drawer.addView(lblProperties); drawer.addView(lblDownload); drawer.addView(lblSettings); drawer.addView(lblLocal); drawer.addView(fileNavView); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!drawerLayout.isDrawerOpen(Gravity.LEFT)) drawerLayout.openDrawer(Gravity.LEFT); else drawerLayout.closeDrawer(Gravity.LEFT); } }); }