List of usage examples for android.widget LinearLayout setOrientation
public void setOrientation(@OrientationMode int orientation)
From source file:ovh.ice.icecons.MainActivity.java
private void createLayout() { // main centered layout LinearLayout.LayoutParams smallLayoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1f); float scale = IceScreenUtils.densityScale(getApplicationContext()); ViewGroup.LayoutParams buttonParams = new ViewGroup.LayoutParams(Math.round(48 * scale), Math.round(48 * scale)); LinearLayout frameLayout = new LinearLayout(this); frameLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT)); frameLayout.setBackgroundColor(0xffffffff); frameLayout.setGravity(Gravity.CENTER); setContentView(frameLayout);//from ww w . ja v a 2s.com LinearLayout baseLayout = new LinearLayout(this); baseLayout.setOrientation(LinearLayout.VERTICAL); baseLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT)); baseLayout.setGravity(Gravity.LEFT); frameLayout.addView(baseLayout); // wallpaper button LinearLayout wallpaperLayout = new LinearLayout(this); wallpaperLayout.setOrientation(LinearLayout.HORIZONTAL); wallpaperLayout.setLayoutParams(smallLayoutParams); wallpaperLayout.setGravity(Gravity.CENTER_VERTICAL); baseLayout.addView(wallpaperLayout); LinearLayout wallpaperClickLayout = new LinearLayout(this); wallpaperClickLayout.setOrientation(LinearLayout.HORIZONTAL); wallpaperClickLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); wallpaperClickLayout.setGravity(Gravity.CENTER); wallpaperLayout.addView(wallpaperClickLayout); wallpaperClickLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { wallpaperPicker(v); } }); Button wallpaperButton = new Button(this); wallpaperButton.setLayoutParams(buttonParams); wallpaperButton.setBackground( new BitmapDrawable(getResources(), IceImageUtils.bitmapLoad(getApplicationContext().getResources(), R.drawable.ic_wallpaper_button, Math.round(48 * scale), Math.round(48 * scale)))); wallpaperClickLayout.addView(wallpaperButton); TextView wallpaperText = new TextView(this); wallpaperText.setText("wallpapers"); wallpaperText.setTextSize(24); wallpaperText.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.colorPrimaryDark)); wallpaperText.setPadding(64, 64, 64, 64); wallpaperClickLayout.addView(wallpaperText); // icon view button LinearLayout iconLayout = new LinearLayout(this); iconLayout.setOrientation(LinearLayout.HORIZONTAL); iconLayout.setLayoutParams(smallLayoutParams); iconLayout.setGravity(Gravity.CENTER_VERTICAL); baseLayout.addView(iconLayout); LinearLayout iconClickLayout = new LinearLayout(this); iconClickLayout.setOrientation(LinearLayout.HORIZONTAL); iconClickLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); iconClickLayout.setGravity(Gravity.CENTER); iconLayout.addView(iconClickLayout); iconClickLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { iconView(v); } }); Button iconButton = new Button(this); iconButton.setLayoutParams(buttonParams); iconButton.setBackground( new BitmapDrawable(getResources(), IceImageUtils.bitmapLoad(getApplicationContext().getResources(), R.drawable.ic_icon_button, Math.round(48 * scale), Math.round(48 * scale)))); iconClickLayout.addView(iconButton); TextView iconText = new TextView(this); iconText.setText("view icons"); iconText.setTextSize(24); iconText.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.colorPrimaryDark)); iconText.setPadding(64, 64, 64, 64); iconClickLayout.addView(iconText); // source code button LinearLayout sourceLayout = new LinearLayout(this); sourceLayout.setOrientation(LinearLayout.HORIZONTAL); sourceLayout.setLayoutParams(smallLayoutParams); sourceLayout.setGravity(Gravity.CENTER_VERTICAL); baseLayout.addView(sourceLayout); LinearLayout sourceClickLayout = new LinearLayout(this); sourceClickLayout.setOrientation(LinearLayout.HORIZONTAL); sourceClickLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); sourceClickLayout.setGravity(Gravity.CENTER); sourceLayout.addView(sourceClickLayout); sourceClickLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { gitLink(v); } }); Button sourceButton = new Button(this); sourceButton.setLayoutParams(buttonParams); sourceButton.setBackground( new BitmapDrawable(getResources(), IceImageUtils.bitmapLoad(getApplicationContext().getResources(), R.drawable.ic_source_button, Math.round(48 * scale), Math.round(48 * scale)))); sourceClickLayout.addView(sourceButton); TextView sourceText = new TextView(this); sourceText.setText("source code"); sourceText.setTextSize(24); sourceText.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.colorPrimaryDark)); sourceText.setPadding(64, 64, 64, 64); sourceClickLayout.addView(sourceText); // license button LinearLayout aboutLayout = new LinearLayout(this); aboutLayout.setOrientation(LinearLayout.HORIZONTAL); aboutLayout.setLayoutParams(smallLayoutParams); aboutLayout.setGravity(Gravity.CENTER_VERTICAL); baseLayout.addView(aboutLayout); LinearLayout aboutClickLayout = new LinearLayout(this); aboutClickLayout.setOrientation(LinearLayout.HORIZONTAL); aboutClickLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); aboutClickLayout.setGravity(Gravity.CENTER); aboutLayout.addView(aboutClickLayout); aboutClickLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { licenseShow(v); } }); Button aboutButton = new Button(this); aboutButton.setLayoutParams(buttonParams); aboutButton.setBackground( new BitmapDrawable(getResources(), IceImageUtils.bitmapLoad(getApplicationContext().getResources(), R.drawable.ic_license_button, Math.round(48 * scale), Math.round(48 * scale)))); aboutClickLayout.addView(aboutButton); TextView aboutText = new TextView(this); aboutText.setText("license"); aboutText.setTextSize(24); aboutText.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.colorPrimaryDark)); aboutText.setPadding(64, 64, 64, 64); aboutClickLayout.addView(aboutText); }
From source file:eu.power_switch.gui.adapter.SceneRecyclerViewAdapter.java
@Override public void onBindViewHolder(final ViewHolder holder, int position) { final Scene scene = scenes.get(holder.getAdapterPosition()); String inflaterString = Context.LAYOUT_INFLATER_SERVICE; LayoutInflater inflater = (LayoutInflater) fragmentActivity.getSystemService(inflaterString); holder.sceneName.setText(scene.getName()); holder.sceneName.setOnClickListener(new View.OnClickListener() { @Override//from w w w. j av a 2 s . com public void onClick(View v) { if (holder.linearLayoutSceneItems.getVisibility() == View.VISIBLE) { holder.linearLayoutSceneItems.setVisibility(View.GONE); } else { holder.linearLayoutSceneItems.setVisibility(View.VISIBLE); } } }); holder.sceneName.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { if (onItemLongClickListener != null) { onItemLongClickListener.onItemLongClick(v, holder.getAdapterPosition()); } return true; } }); holder.buttonActivateScene.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (SmartphonePreferencesHandler.getVibrateOnButtonPress()) { VibrationHandler.vibrate(fragmentActivity, SmartphonePreferencesHandler.getVibrationDuration()); } new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { ActionHandler.execute(fragmentActivity, scene); return null; } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } }); // clear previous items holder.linearLayoutSceneItems.removeAllViews(); // hide setup by default holder.linearLayoutSceneItems.setVisibility(View.GONE); // add current setup for (final SceneItem sceneItem : scene.getSceneItems()) { // create a new receiverRow for our current receiver and add it // to our table of all devices of our current room // the row will contain the device name and all buttons LinearLayout receiverRow = new LinearLayout(fragmentActivity); receiverRow.setOrientation(LinearLayout.HORIZONTAL); holder.linearLayoutSceneItems.addView(receiverRow); // setup TextView to display receiver name AppCompatTextView receiverName = new AppCompatTextView(fragmentActivity); receiverName.setText(sceneItem.getReceiver().getName()); receiverName.setTextSize(18); receiverName .setTextColor(ThemeHelper.getThemeAttrColor(fragmentActivity, android.R.attr.textColorPrimary)); receiverName.setGravity(Gravity.CENTER_VERTICAL); receiverRow.addView(receiverName, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1.0f)); TableLayout buttonLayout = new TableLayout(fragmentActivity); receiverRow.addView(buttonLayout, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); int buttonsPerRow; if (sceneItem.getReceiver().getButtons().size() % 3 == 0) { buttonsPerRow = 3; } else { buttonsPerRow = 2; } int i = 0; TableRow buttonRow = null; for (final Button button : sceneItem.getReceiver().getButtons()) { final android.widget.Button buttonView = (android.widget.Button) inflater .inflate(R.layout.simple_button, buttonRow, false); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { buttonView.setElevation(0); buttonView.setStateListAnimator(null); } buttonView.setText(button.getName()); buttonView.setEnabled(false); final int accentColor = ThemeHelper.getThemeAttrColor(fragmentActivity, R.attr.colorAccent); final int inactiveColor = ThemeHelper.getThemeAttrColor(fragmentActivity, R.attr.textColorInactive); if (sceneItem.getActiveButton().equals(button)) { buttonView.setTextColor(accentColor); } else { buttonView.setTextColor(inactiveColor); } if (i == 0 || i % buttonsPerRow == 0) { buttonRow = new TableRow(fragmentActivity); buttonRow.setLayoutParams( new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); buttonRow.addView(buttonView); buttonLayout.addView(buttonRow); } else { buttonRow.addView(buttonView); } i++; } } if (holder.getAdapterPosition() == getItemCount() - 1) { holder.footer.setVisibility(View.VISIBLE); } else { holder.footer.setVisibility(View.GONE); } }
From source file:me.cpwc.nibblegram.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 {//from ww w .jav a 2s.c o 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); } }
From source file:com.summer.framework.ui.widget.FragmentTabHost.java
private void ensureHierarchy(Context context) { // If owner hasn't made its own view hierarchy, then as a convenience // we will construct a standard one here. if (findViewById(android.R.id.tabs) == null) { LinearLayout ll = new LinearLayout(context); ll.setOrientation(LinearLayout.VERTICAL); addView(ll, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); TabWidget tw = new TabWidget(context); tw.setId(android.R.id.tabs);//from w w w . j av a2s .co m tw.setOrientation(LinearLayout.HORIZONTAL); ll.addView(tw, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0)); FrameLayout fl = new FrameLayout(context); fl.setId(android.R.id.tabcontent); ll.addView(fl, new LinearLayout.LayoutParams(0, 0, 0)); mRealTabContent = fl = new FrameLayout(context); mRealTabContent.setId(mContainerId); ll.addView(fl, new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT, 0, 1)); } }
From source file:com.anlddev.customwidget.widget.AFragmentTabHost.java
private void ensureHierarchy(Context context) { // If owner hasn't made its own view hierarchy, then as a convenience // we will construct a standard one here. if (findViewById(android.R.id.tabs) == null) { LinearLayout ll = new LinearLayout(context); ll.setOrientation(LinearLayout.VERTICAL); addView(ll, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); TabWidget tw = new TabWidget(context); tw.setId(android.R.id.tabs);//from www . j av a2s . c o m tw.setOrientation(TabWidget.HORIZONTAL); ll.addView(tw, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0)); FrameLayout fl = new FrameLayout(context); fl.setId(android.R.id.tabcontent); ll.addView(fl, new LinearLayout.LayoutParams(0, 0, 0)); mRealTabContent = fl = new FrameLayout(context); mRealTabContent.setId(mContainerId); ll.addView(fl, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 1)); } }
From source file:hoahong.facebook.messenger.ui.EmojiView.java
private void init() { setOrientation(LinearLayout.VERTICAL); for (int i = 0; i < Emoji.data.length; i++) { GridView gridView = new GridView(getContext()); if (Utils.isTablet()) { gridView.setColumnWidth(Utils.dp(60)); } else {//w ww . j a v a2 s. c o m gridView.setColumnWidth(Utils.dp(45)); } gridView.setNumColumns(-1); 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(Utils.dpf(2.0f)); tabs.setUnderlineHeight(Utils.dpf(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(Utils.dp(61), LayoutParams.MATCH_PARENT)); recentsWrap = new FrameLayout(getContext()); recentsWrap.addView(views.get(0)); TextView localTextView = new TextView(getContext()); localTextView.setText("No recent"); localTextView.setTextSize(18.0f); localTextView.setTextColor(-7829368); localTextView.setGravity(17); recentsWrap.addView(localTextView); views.get(0).setEmptyView(localTextView); addView(localLinearLayout, new LinearLayout.LayoutParams(-1, Utils.dpf(48.0f))); addView(pager); loadRecents(); if (Emoji.data[0] == null || Emoji.data[0].length == 0) { pager.setCurrentItem(1); } }
From source file:org.telegram.ui.Views.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 {//from www .j a v a 2s .c om gridView.setColumnWidth(AndroidUtilities.dp(45)); } gridView.setNumColumns(-1); 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(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.dpf(48.0f))); addView(pager); loadRecents(); if (Emoji.data[0] == null || Emoji.data[0].length == 0) { pager.setCurrentItem(1); } }
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 {// w w w . j ava 2 s .com 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:com.google.android.gcm.demo.ui.NetworkSchedulerFragment.java
@Override public void refresh() { FrameLayout tasksView = (FrameLayout) getActivity().findViewById(R.id.scheduler_tasks); // the view might have been destroyed, in which case we don't do anything if (tasksView != null) { float density = getActivity().getResources().getDisplayMetrics().density; SimpleArrayMap<String, TaskTracker> tasks = mTasks.getTasks(); LinearLayout tasksList = new LinearLayout(getActivity()); tasksList.setOrientation(LinearLayout.VERTICAL); for (int i = 0; i < tasks.size(); i++) { final TaskTracker task = tasks.valueAt(i); CardView taskCard = (CardView) getActivity().getLayoutInflater().inflate(R.layout.widget_task, tasksList, false);//from w w w . j a v a 2s . c o m ImageView taskIcon = (ImageView) taskCard.findViewById(R.id.task_icon); taskIcon.setImageResource(R.drawable.check_circle_grey600); taskIcon.setPadding(0, 0, (int) (8 * density), 0); TextView taskLabel = (TextView) taskCard.findViewById(R.id.task_title); TextView taskParams = (TextView) taskCard.findViewById(R.id.task_params); if (task.period == 0) { taskLabel.setText(getString(R.string.scheduler_oneoff, task.tag)); taskParams.setText(getString(R.string.scheduler_oneoff_params, task.windowStartElapsedSecs, task.windowStopElapsedSecs)); } else { taskLabel.setText(getString(R.string.scheduler_periodic, task.tag)); taskParams.setText(getString(R.string.scheduler_periodic_params, task.period, task.flex)); } TextView taskCreatedAt = (TextView) taskCard.findViewById(R.id.task_created_at); taskCreatedAt.setText(getString(R.string.scheduler_secs_ago, DateUtils .formatElapsedTime(SystemClock.elapsedRealtime() / 1000 - task.createdAtElapsedSecs))); TextView lastExecuted = (TextView) taskCard.findViewById(R.id.task_last_exec); if (task.executionTimes.isEmpty()) { lastExecuted.setText(getString(R.string.scheduler_na)); } else { long lastExecTime = task.executionTimes.get(task.executionTimes.size() - 1); lastExecuted.setText(getString(R.string.scheduler_secs_ago, DateUtils.formatElapsedTime(SystemClock.elapsedRealtime() / 1000 - lastExecTime))); } TextView state = (TextView) taskCard.findViewById(R.id.task_state); if (task.isCancelled()) { state.setText(getString(R.string.scheduler_cancelled)); } else if (task.isExecuted()) { state.setText(getString(R.string.scheduler_executed)); } else { state.setText(getString(R.string.scheduler_pending)); } Button cancel = (Button) taskCard.findViewById(R.id.task_cancel); cancel.setVisibility(View.VISIBLE); cancel.setText(R.string.scheduler_cancel); Button delete = (Button) taskCard.findViewById(R.id.task_delete); delete.setVisibility(View.VISIBLE); delete.setText(R.string.scheduler_delete); if (!task.isCancelled() && (!task.isExecuted() || task.period != 0)) { cancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { cancelTask(task.tag); refresh(); } }); cancel.setEnabled(true); delete.setEnabled(false); } else { cancel.setEnabled(false); delete.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mTasks.deleteTask(task.tag); refresh(); } }); delete.setEnabled(true); } tasksList.addView(taskCard); } tasksView.removeAllViews(); tasksView.addView(tasksList); } }
From source file:com.ustc.dystu.dandelion.fragment.BaseFragmentTabHost.java
private void initFragmentTabHost(Context context, AttributeSet attrs) { TypedArray a = context.obtainStyledAttributes(attrs, new int[] { android.R.attr.inflatedId }, 0, 0); mContainerId = a.getResourceId(0, 0); a.recycle();/*w ww. j a v a 2 s. c o m*/ super.setOnTabChangedListener(this); // If owner hasn't made its own view hierarchy, then as a convenience // we will construct a standard one here. if (findViewById(android.R.id.tabs) == null) { LinearLayout ll = new LinearLayout(context); ll.setOrientation(LinearLayout.VERTICAL); addView(ll, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); TabWidget tw = new TabWidget(context); tw.setId(android.R.id.tabs); tw.setOrientation(TabWidget.HORIZONTAL); tw.setDividerDrawable(null);//?ab? ll.addView(tw, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0)); FrameLayout fl = new FrameLayout(context); fl.setId(android.R.id.tabcontent); ll.addView(fl, new LinearLayout.LayoutParams(0, 0, 0)); mRealTabContent = fl = new FrameLayout(context); mRealTabContent.setId(mContainerId); ll.addView(fl, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, 0, 1)); } }