List of usage examples for android.widget ImageButton ImageButton
public ImageButton(Context context)
From source file:com.wanderingcan.persistentsearch.PersistentSearchView.java
@SuppressWarnings("deprecation") private void initialize(Context context, AttributeSet attrs, int defStyleAttr) { mNavIcon = new ImageButton(context); mEndIcon = new ImageButton(context); mSearchText = new EditText(context); mSearchMenuView = new SearchMenuView(context); mDivider = new View(context); mDivider.setVisibility(GONE);/*from ww w.j a v a 2s . co m*/ mPresenter = new SearchMenuPresenter(context, new SearchMenuListener()); mSearchMenuView.setAdapter(mPresenter.mAdapter); mSearchMenuView.addItemDecoration(new DividerItemDecoration(context, attrs)); int[] attr = { android.R.attr.listDivider }; TypedArray ta = context.obtainStyledAttributes(attr); Drawable divider = ta.getDrawable(0); ta.recycle(); mOpened = false; mShowClearDrawable = false; mShowMenu = true; //Set up CardView setUseCompatPadding(true); setFocusable(true); setFocusableInTouchMode(true); //Set up TextView if (Build.VERSION.SDK_INT >= 16) { mSearchText.setBackground(null); mNavIcon.setBackground(null); mEndIcon.setBackground(null); mDivider.setBackground(divider); } else { mSearchText.setBackgroundDrawable(null); mNavIcon.setBackgroundDrawable(null); mEndIcon.setBackgroundDrawable(null); mDivider.setBackgroundDrawable(divider); } mSearchText.setSingleLine(); mHintVisible = false; mSearchText.setOnFocusChangeListener(new SearchFocusListener()); mSearchText.setOnEditorActionListener(new EditTextEditorAction()); mSearchText.setImeOptions(EditorInfo.IME_ACTION_SEARCH); mSearchText.addTextChangedListener(new EditTextTextWatcher()); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PersistentSearchView, defStyleAttr, 0); Drawable drawable = a.getDrawable(R.styleable.PersistentSearchView_navSrc); setNavigationDrawable(drawable); mNavIcon.setScaleType(ImageView.ScaleType.FIT_CENTER); mNavIcon.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mIconListener != null) { mIconListener.OnNavigationIconClick(); } } }); drawable = a.getDrawable(R.styleable.PersistentSearchView_endSrc); setEndDrawable(drawable); mClearDrawable = ContextCompat.getDrawable(getContext(), R.drawable.ic_action_cancel); mEndIcon.setScaleType(ImageView.ScaleType.FIT_CENTER); mEndIcon.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mShowClearDrawable) { //Clears the text mSearchText.setText(EMPTY); } else { if (mIconListener != null) { mIconListener.OnEndIconClick(); } } } }); mHint = a.getText(R.styleable.PersistentSearchView_hint); mHintAlwaysVisible = a.getBoolean(R.styleable.PersistentSearchView_hintAlwaysActive, false); if (mHintAlwaysVisible) { mSearchText.setHint(mHint); } a.recycle(); Resources res = context.getResources(); int imageDimen = res.getDimensionPixelSize(R.dimen.persistent_search_view_image_dimen); mImageMargin = res.getDimensionPixelSize(R.dimen.persistent_search_view_image_side_margin); int imageTopMargin = res.getDimensionPixelSize(R.dimen.persistent_search_view_image_top_margin); //Sets all of the locations of the views CardView.LayoutParams lpNav = generateDefaultLayoutParams(); lpNav.width = lpNav.height = imageDimen; CardView.LayoutParams lpEnd = (LayoutParams) generateLayoutParams(lpNav); lpNav.gravity = Gravity.START; lpEnd.gravity = Gravity.END; if (Build.VERSION.SDK_INT >= 17) { mNavIcon.setPaddingRelative(mImageMargin, imageTopMargin, mImageMargin / 2, imageTopMargin); mEndIcon.setPaddingRelative(mImageMargin / 2, imageTopMargin, mImageMargin, imageTopMargin); } else { mNavIcon.setPadding(mImageMargin, imageTopMargin, mImageMargin / 2, imageTopMargin); mEndIcon.setPadding(mImageMargin / 2, imageTopMargin, mImageMargin, imageTopMargin); } CardView.LayoutParams lpText = generateDefaultLayoutParams(); lpText.gravity = Gravity.TOP; lpText.height = lpNav.topMargin + lpNav.height; mTextMargin = res.getDimensionPixelSize(R.dimen.persistent_search_view_text_margin); if (Build.VERSION.SDK_INT >= 17) { lpText.setMarginStart(mTextMargin); lpText.setMarginEnd(mTextMargin); } else { lpText.leftMargin = lpText.rightMargin = mTextMargin; } lpText = setupSearchTextMargin(lpText); CardView.LayoutParams lpMenu = generateDefaultLayoutParams(); lpMenu.topMargin = lpNav.topMargin + lpNav.height; lpMenu.height = RecyclerView.LayoutParams.WRAP_CONTENT; CardView.LayoutParams lpDivider = generateDefaultLayoutParams(); if (divider != null) { lpDivider.height = divider.getIntrinsicHeight(); } lpDivider.topMargin = lpNav.topMargin + lpNav.height; //Adds the views to the PersistentSearchView addView(mNavIcon, lpNav); addView(mEndIcon, lpEnd); addView(mSearchText, lpText); addView(mSearchMenuView, lpMenu); addView(mDivider, lpDivider); }
From source file:piuk.blockchain.android.util.ActionBarFragment.java
public ImageButton getButton(final int drawableRes) { final ImageButton button = new ImageButton(getActivity()); button.setImageResource(drawableRes); button.setBackgroundResource(R.drawable.action_bar_background); button.setPadding(0, 0, 0, 0);/*from w w w . ja v a2 s . c om*/ return button; }
From source file:de.uulm.graphicalpasswords.openuyi.UYIPagerAdapter.java
@Override public Object instantiateItem(View collection, int pos) { LayoutInflater inflater = (LayoutInflater) collection.getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); int page = 0; switch (pos) { case 1:/*from w ww. j a va 2 s .co m*/ page = R.layout.uyipage2; break; case 2: page = R.layout.uyipage3; break; default: page = R.layout.uyipage1; break; } View view = inflater.inflate(page, null); TableLayout currentTable; switch (pos) { case 1: currentTable = (TableLayout) view.findViewById(R.id.uyi_tablelayout_page2); break; case 2: currentTable = (TableLayout) view.findViewById(R.id.uyi_tablelayout_page3); break; default: currentTable = (TableLayout) view.findViewById(R.id.uyi_tablelayout_page1); break; } // Add ImageButtons to TableLayout int index = 0; for (int i = 0; i < 3; i++) { TableRow currentRow = new TableRow(view.getContext()); for (int j = 0; j < 3; j++) { ImageButton button = new ImageButton(view.getContext()); button.setBackgroundColor(Color.TRANSPARENT); button.setPadding(3, 3, 3, 3); button.setAdjustViewBounds(true); button.setOnClickListener(clickListener); button.setImageResource(picture_arrays[pos][index]); button.setId(picture_arrays[pos][index]); button.setClickable(true); index++; currentRow.addView(button); } currentTable.addView(currentRow); } ((ViewPager) collection).addView(view, 0); return view; }
From source file:com.woodblockwithoutco.quickcontroldock.model.impl.actions.flashlight.FlashlightService.java
@Override public void onCreate() { sIsRunning = true;//from w w w .ja v a 2s .c o m NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder.setContentTitle(getResources().getString(R.string.persistent_flash_active)); builder.setContentText(getResources().getString(R.string.persistent_flash_active_tap)); builder.setSmallIcon(R.drawable.ic_persistent_flash); builder.setContentIntent( PendingIntent.getBroadcast(this, -1, new Intent(getPackageName() + ".STOP_FLASH"), 0)); startForeground(NOTIFICATION_ID, builder.build()); mContainer = new LinearLayout(getApplicationContext()); LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); mContainer.setLayoutParams(lparams); mContainer.setOrientation(LinearLayout.VERTICAL); mTurnOffButton = new ImageButton(getApplicationContext()); mTurnOffButton.setImageResource(R.drawable.ic_persistent_flash); mTurnOffButton.setBackgroundColor(0x80000000); mTurnOffButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { stopSelf(); } }); mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE); WindowManager.LayoutParams params = new WindowManager.LayoutParams(); params.type = ConstantHolder.getLockscreenType(); params.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; params.x = 0; params.y = 0; params.width = WindowManager.LayoutParams.WRAP_CONTENT; params.height = params.width; params.gravity = Gravity.CENTER; params.format = PixelFormat.TRANSLUCENT; mContainer.addView(mTurnOffButton); String method = TogglesResolver.getFlashlightType(getApplicationContext()); if (method.equals("default")) { mDummySurfaceView = new SurfaceView(getApplicationContext()); mDummySurfaceView.setAlpha(0.01f); ViewGroup.LayoutParams sparams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, 1); mDummySurfaceView.setLayoutParams(sparams); mFlashManipulator = new DefaultFlashlightManipulator(mDummySurfaceView); mContainer.addView(mDummySurfaceView); } else if (method.equals("htc")) { mFlashManipulator = new HTCFlashlightManipulator(); } else if (method.equals("nosurfaceview")) { mFlashManipulator = new NoSurfaceViewFlashlightManipulator(); } else { mDummySurfaceView = new SurfaceView(getApplicationContext()); mDummySurfaceView.setAlpha(0.01f); ViewGroup.LayoutParams sparams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, 1); mDummySurfaceView.setLayoutParams(sparams); mFlashManipulator = new DefaultFlashlightManipulator(mDummySurfaceView); mContainer.addView(mDummySurfaceView); } mWindowManager.addView(mContainer, params); mHandler = new Handler(); mActor = new Runnable() { @Override public void run() { mFlashManipulator.turnFlashlightOn(); } }; mScreenOffReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { mFlashManipulator.turnFlashlightOff(); mHandler.postDelayed(mActor, 200); } }; mStopServiceReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { mFlashManipulator.turnFlashlightOff(); stopSelf(); } }; registerReceiver(mScreenOffReceiver, new IntentFilter(Intent.ACTION_SCREEN_OFF)); registerReceiver(mStopServiceReceiver, new IntentFilter(getPackageName() + ".STOP_FLASH")); }
From source file:com.intel.xdk.device.Device.java
@Override public void initialize(CordovaInterface cordova, final CordovaWebView webView) { super.initialize(cordova, webView); this.activity = cordova.getActivity(); this.webView = webView; //remote site support remoteLayout = new AbsoluteLayout(activity); remoteLayout.setBackgroundColor(Color.BLACK); //hide the remote site display until needed remoteLayout.setVisibility(View.GONE); //create the close button remoteClose = new ImageButton(activity); remoteClose.setBackgroundColor(Color.TRANSPARENT); Drawable remoteCloseImage = null;/*from w w w.ja v a 2 s . co m*/ remoteCloseImage = activity.getResources().getDrawable( activity.getResources().getIdentifier("remote_close", "drawable", activity.getPackageName())); File remoteCloseImageFile = new File(activity.getFilesDir(), "_intelxdk/remote_close.png"); if (remoteCloseImageFile.exists()) { remoteCloseImage = (Drawable.createFromPath(remoteCloseImageFile.getAbsolutePath())); } else { remoteCloseImage = (activity.getResources().getDrawable( activity.getResources().getIdentifier("remote_close", "drawable", activity.getPackageName()))); } //set the button image //remoteClose.setImageDrawable(remoteCloseImage); remoteClose.setBackgroundDrawable(remoteCloseImage); //set up the button click action remoteClose.setOnClickListener(new OnClickListener() { public void onClick(View v) { closeRemoteSite(); } }); //add the close button remoteLayout.addView(remoteClose); final ViewGroup parent = (ViewGroup) webView.getEngine().getView().getParent(); activity.runOnUiThread(new Runnable() { public void run() { if (parent != null) { //add layout to activity root layout parent.addView(remoteLayout, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, Gravity.CENTER)); } } }); //Initialize the orientation. lastOrientation = "unknown"; //Listen to the orientation change. OrientationEventListener listener = new OrientationEventListener(activity) { @Override public void onOrientationChanged(int orientation) { //Log.d("orientation","orientation: " + orientation); String currentOrientation = "unknown"; boolean orientationChanged = false; //int displayOrientation = 0; if (orientation > 345 || orientation < 15) { currentOrientation = "portrait"; displayOrientation = 0; } else if (orientation > 75 && orientation < 105) { currentOrientation = "landscape"; displayOrientation = 90; } else if (orientation > 165 && orientation < 195) { currentOrientation = "portrait"; displayOrientation = 180; } else if (orientation > 255 && orientation < 285) { currentOrientation = "landscape"; displayOrientation = -90; } if (currentOrientation.equals("unknown")) { currentOrientation = lastOrientation; } if (!currentOrientation.equals(lastOrientation)) { orientationChanged = true; Log.d("orientation", "Orientation changes from " + lastOrientation + " to " + currentOrientation + ", current orientation: " + orientation + "."); } if (orientationChanged) { String js = "javascript:try{intel.xdk.device.orientation='" + displayOrientation + "';}catch(e){}var e = document.createEvent('Events');e.initEvent('intel.xdk.device.orientation.change', true, true);e.success=true;e.orientation='" + displayOrientation + "';document.dispatchEvent(e);"; injectJS(js); } lastOrientation = currentOrientation; } }; listener.enable(); registerScreenStatusReceiver(); //cache references to methods for use in injectJS try { evaluateJavascript = webView.getClass().getMethod("evaluateJavascript", String.class, ValueCallback.class); } catch (Exception e) { } try { sendJavascript = webView.getClass().getMethod("sendJavascript", String.class); } catch (Exception e) { } emptyVC = new ValueCallback<String>() { @Override public void onReceiveValue(String s) { } }; }
From source file:com.example.diplimadoapp.SuperAwesomeCardFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); FrameLayout fl = new FrameLayout(getActivity()); fl.setLayoutParams(params);// w ww . ja va 2 s. com final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); switch (position) { case 0: LinearLayout ll = new LinearLayout(getActivity()); ll.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); ll.setOrientation(LinearLayout.VERTICAL); ImageView iv = new ImageView(getActivity()); iv.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 1020)); //iv.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT)); iv.setMaxHeight(520); iv.setImageResource(R.drawable.contact); ll.addView(iv); TableLayout tl = new TableLayout(getActivity()); tl.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); TableRow tr = new TableRow(getActivity()); tr.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); tr.setGravity(Gravity.FILL_HORIZONTAL); tr.setPadding(5, 5, 5, 5); List<RssItem> lecturaitems = null; try { // Create RSS reader RssReader rssReader = new RssReader( "http://www.senalradionica.gov.co/index.php/home/articulos/itemlist?format=feed"); // Get a ListView from main view //ListView itcItems = (ListView) findViewById(R.id.listMainView); lecturaitems = rssReader.getItems(); } catch (Exception e) { Log.e("Diplomado App Reader", e.getMessage()); } TextView v1 = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v1.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2)); v1.setGravity(Gravity.CENTER); v1.setBackgroundResource(R.drawable.background_card); if (lecturaitems != null) { v1.setText(lecturaitems.get(0).getTitle()); String urlnoticia = lecturaitems.get(0).getLink(); v1.setOnClickListener(new NoticiaDestacadaOnClickListener(urlnoticia)); } else { v1.setText("No Registra nuevas noticias"); } tr.addView(v1); ImageButton ib = new ImageButton(getActivity()); ib.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib.setImageResource(R.drawable.facebook); ib.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW); myWebLink.setData(Uri.parse("http://www.facebook.com")); startActivity(myWebLink); } }); tr.addView(ib); ImageButton ib2 = new ImageButton(getActivity()); ib2.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib2.setImageResource(R.drawable.twitter); ib2.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW); myWebLink.setData(Uri.parse("http://www.twitter.com")); startActivity(myWebLink); } }); tr.addView(ib2); ImageButton ib3 = new ImageButton(getActivity()); ib3.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib3.setImageResource(R.drawable.youtube); ib3.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW); myWebLink.setData(Uri.parse("http://www.youtube.com")); startActivity(myWebLink); } }); tr.addView(ib3); tl.addView(tr); ll.addView(tl); fl.addView(ll); break; case 1: LinearLayout ll2 = new LinearLayout(getActivity()); ll2.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); ll2.setOrientation(LinearLayout.VERTICAL); TableLayout tl2 = new TableLayout(getActivity()); tl2.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); TableRow tr2 = new TableRow(getActivity()); tr2.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); tr2.setGravity(Gravity.FILL_HORIZONTAL); tr2.setPadding(5, 5, 5, 5); TextView v0 = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v0.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2)); v0.setGravity(Gravity.CENTER); v0.setText("Acusticos Radionoca. Lunes a Viernes 8:00 a.m. - 9:00 a.m."); tr2.addView(v0); ImageButton ib20 = new ImageButton(getActivity()); ib20.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib20.setImageResource(R.drawable.pacusticos); ib20.setBackgroundDrawable(null); tr2.addView(ib20); tl2.addView(tr2); TableRow tr3 = new TableRow(getActivity()); tr3.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); tr3.setGravity(Gravity.FILL_HORIZONTAL); tr3.setPadding(5, 5, 5, 5); TextView v03 = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v03.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2)); v03.setGravity(Gravity.CENTER); v03.setText("Acusticos Radionoca. Lunes a Viernes 8:00 a.m. - 9:00 a.m."); tr3.addView(v03); ImageButton ib30 = new ImageButton(getActivity()); ib30.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib30.setImageResource(R.drawable.pradionica_lacarta); ib30.setBackgroundDrawable(null); tr3.addView(ib30); tl2.addView(tr3); TableRow tr4 = new TableRow(getActivity()); tr4.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); tr4.setGravity(Gravity.FILL_HORIZONTAL); tr4.setPadding(5, 5, 5, 5); TextView v04 = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v04.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2)); v04.setGravity(Gravity.CENTER); v04.setText("Acusticos Radionoca. Lunes a Viernes 8:00 a.m. - 9:00 a.m."); tr4.addView(v04); tl2.addView(tr4); ImageButton ib40 = new ImageButton(getActivity()); ib40.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib40.setImageResource(R.drawable.prockeros); ib40.setBackgroundDrawable(null); tr4.addView(ib40); ll2.addView(tl2); /* VideoView videoView = new VideoView(getActivity()); Uri path = Uri.parse("rtmp://cdns840stu0010.multistream.net:80/rtvcRadionicalive/?pass=|radionica|"); videoView.setVideoURI(path); videoView.start(); TableRow tr5 =new TableRow(getActivity()); tr5.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT)); tr5.setGravity(Gravity.FILL_HORIZONTAL); tr5.setPadding(5,5,5,5); tr5.addView(videoView); ll2.addView(tr5);*/ fl.addView(ll2); break; case 2: ListView lv = new ListView(getActivity()); params.setMargins(margin, margin, margin, margin); lv.setLayoutParams(params); lv.setLayoutParams(params); lv.setBackgroundResource(R.drawable.background_card); try { // Create RSS reader RssReader rssReader = new RssReader( "http://www.senalradionica.gov.co/index.php/home/articulos/itemlist?format=feed"); // Get a ListView from main view //ListView itcItems = (ListView) findViewById(R.id.listMainView); List<RssItem> lecturaitems2 = rssReader.getItems(); // Create a list adapter ArrayAdapter<RssItem> adapter = new ArrayAdapter<RssItem>(getActivity(), android.R.layout.simple_list_item_1, lecturaitems2); // Set list adapter for the ListView lv.setAdapter(adapter); // Set list view item click listener lv.setOnItemClickListener(new ListListener(lecturaitems2, getActivity())); } catch (Exception e) { Log.e("Diplomado App Reader", e.getMessage()); } fl.addView(lv); break; } return fl; }
From source file:org.borderstone.tagtags.TTProtocolActivity.java
@Override public void onCreate(Bundle bundle) { super.onCreate(bundle); this.setContentView(R.layout.activity_protocol); this.setTheme(R.style.AppTheme); if (Constants.files.contains(Constants.filename)) { int idex = Constants.files.indexOf(Constants.filename); row = Constants.file_rows.get(idex); }/* w w w.j a v a2 s . c o m*/ lblGlobal = new BTitleLabel(this); lblLocal = new BTitleLabel(this); btnUpload = new BButton(this); lblGlobal.setPadding(15, 15, 15, 15); lblLocal.setPadding(15, 15, 15, 15); lblGlobal.setGravity(Gravity.CENTER); lblLocal.setGravity(Gravity.CENTER); lblLocal.setTextColor(Color.WHITE); lblGlobal.setTextColor(Color.WHITE); lblLocal.setTextSize(Constants.fontSize + 2); lblGlobal.setTextSize(Constants.fontSize + 2); lblGlobal.setText("GLOBAL PROPERTIES"); lblLocal.setText("TECHNICAL MATERIAL"); widgetLayout = new BMultiColumnLayout(this); mDrawerList = (LinearLayout) this.findViewById(R.id.protocolDrawer); lockSwitch = new Switch(this); btnUpload.setOnClickListener(this); btnUpload.setIcon(R.drawable.upload); btnUpload.setText("Upload data"); btnGPS = new ImageButton(this); btnGPS.setOnClickListener(this); btnGPS.setLongClickable(true); btnGPS.setOnLongClickListener(this); DisplayMetrics metrics = getResources().getDisplayMetrics(); DrawerLayout.LayoutParams lp = new DrawerLayout.LayoutParams(metrics.densityDpi * 2, LinearLayout.LayoutParams.MATCH_PARENT); lp.gravity = Gravity.START; sv = (ScrollView) this.findViewById(R.id.protocolBack); widgetLayout.setLayoutParams(Constants.defaultParams); sv.addView(widgetLayout); sv.setLayoutTransition(new LayoutTransition()); toolbar = (Toolbar) this.findViewById(R.id.protToolbar); this.setSupportActionBar(toolbar); toolbar.setNavigationIcon(R.drawable.drawer); toolbar.inflateMenu(R.menu.protocol_menu); toolbar.addView(lockSwitch); lblPercent = new BTitleLabel(this); lblInfo = new BInfoLabel(this); drawProtocolPage(); widgetLayout.setFocusable(true); widgetLayout.setFocusableInTouchMode(true); widgetLayout.requestFocus(); mDrawerList.bringToFront(); final DrawerLayout drawerLayout = (DrawerLayout) this.findViewById(R.id.drawerLayoutProtocol); 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); } }); }
From source file:com.javielinux.utils.SplitActionBarMenu.java
private void loadActionButtons(ArrayList<String> codes, final InfoTweet infoTweet, final long ownerColumn) { main_layout.removeAllViews();//from w w w .ja va2 s.co m boolean is_first = true; for (final String code : codes) { if (is_first) { is_first = false; } else { LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 0.0f); layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT; layoutParams.width = LinearLayout.LayoutParams.WRAP_CONTENT; ImageView imageView = new ImageView(activity); imageView.setBackgroundResource(R.drawable.action_bar_divider); imageView.setLayoutParams(layoutParams); main_layout.addView(imageView); } final InfoSubMenuTweet infoSubMenuTweet = new InfoSubMenuTweet(activity, code); ImageButton imageButton = new ImageButton(activity); imageButton.setBackgroundResource(R.drawable.default_background); int padding = (int) activity.getResources().getDimension(R.dimen.default_padding); imageButton.setPadding(padding, padding, padding, padding); imageButton.setImageResource(infoSubMenuTweet.getResDrawable()); imageButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { hideSplitActionBarMenu(); TweetActions.execByCode(code, activity, ownerColumn, infoTweet, getFromFragment()); } }); imageButton.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { Utils.showMessage(activity, activity.getResources().getString(infoSubMenuTweet.getResName())); return true; } }); main_layout.addView(imageButton); } }
From source file:com.negaheno.ui.Components.PagerSlidingTabStrip.java
private void addIconTab(final int position, int resId) { ImageButton tab = new ImageButton(getContext()); tab.setFocusable(true);//from w w w .j a va2 s . co m tab.setImageResource(resId); tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pager.setCurrentItem(position); } }); tabsContainer.addView(tab); tab.setSelected(position == currentPosition); }
From source file:de.mrapp.android.view.FloatingActionButton.java
/** * Inflates the view's layout.//from www . ja v a 2s .com */ private void inflateLayout() { imageButton = new ImageButton(getContext()); LayoutParams layoutParams = new LayoutParams(0, 0); layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); addView(imageButton, layoutParams); }