List of usage examples for android.widget LinearLayout addView
public void addView(View child)
Adds a child view.
From source file:com.emobc.android.activities.generators.FormActivityGenerator.java
@Override protected void loadAppLevelData(final Activity activity, final AppLevelData data) { this.item = (FormLevelDataItem) data.findByNextLevel(nextLevel); //rotateScreen(activity); initializeHeader(activity, item);/*www. jav a 2 s . c o m*/ controlsMap = new HashMap<String, View>(); //Create Banner CreateMenus c = (CreateMenus) activity; c.createBanner(); LinearLayout formLayout = (LinearLayout) activity.findViewById(R.id.formLayout); for (FormDataItem dataItem : item.getList()) { TextView label = new TextView(activity); label.setText(dataItem.getFieldLabel()); formLayout.addView(label); insertField(activity, dataItem, formLayout); } Button submit = new Button(activity); submit.setText(R.string.form_submit_buttom); submit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { processSubmit(activity); } }); formLayout.addView(submit); ((FormActivity) activity).setControlsMap(controlsMap); }
From source file:com.cleanwiz.applock.ui.adapter.AppPagerAdapter.java
private View buildPagerView(final List<CommLockInfo> pData) { View pagerView = mInflater.inflate(R.layout.pager_applock_old, null); LinearLayout layout_lines = (LinearLayout) pagerView.findViewById(R.id.layout_lines); List<LinearLayout> lines = new ArrayList<LinearLayout>(); for (int i = 0; i < line_num; i++) { LinearLayout line = new LinearLayout(mContext); line.setOrientation(LinearLayout.HORIZONTAL); lines.add(line);// w w w. j av a2 s .c om layout_lines.addView(line); } int num = 0; for (CommLockInfo lockInfo : pData) { View appView = buildAppView(lockInfo); lines.get(num++ / APP_GRID_COLUMN).addView(appView); } return pagerView; }
From source file:com.ess.tudarmstadt.de.sleepsense.mgraph.GraphPlotFragment.java
private void createGraph(String graphTitle, GraphViewSeries series, final int Rid, boolean isBarChart) { GraphView graphView = null;/*from w w w .j a va 2s . com*/ if (isBarChart) { graphView = new BarGraphView(getActivity().getApplicationContext(), graphTitle); // graphView.setVerticalLabels(new String[] { "high", "mid", "low" // }); // graphView.setManualYAxisBounds(11.0d, 9.0d); } else graphView = new LineGraphView(getActivity().getApplicationContext(), graphTitle); graphView.setCustomLabelFormatter(new CustomLabelFormatter() { @Override public String formatLabel(double axis_value, boolean isValueX) { if (isValueX) { // X-Axis // decompose x_axis from adding up before double value = axis_value; if (axis_value >= 200) { value = axis_value - 200; } else if (axis_value > 0) value = axis_value - 100; // make sure not have smth like 4:60 or 11:83 time frame! double whole = value; double fractionalPart = value % 1; double integralPart = value - fractionalPart; if (fractionalPart >= 0.60) { whole = integralPart + 1.0d + (fractionalPart - 0.60); } // convert (double) hour.mm to hour:mm return new DecimalFormat("00.00").format(whole).replaceAll("\\,", ":"); } else { // Y-Axis return new DecimalFormat("#0.00").format(axis_value); } } }); // add data graphView.addSeries(series); graphView.setScrollable(false); // optional - activate scaling / zooming // graphView.setScalable(true); // optional - legend // graphView.setShowLegend(true); if (Rid == R.id.sleep_pattern) { graphView.setManualYAxisBounds(1.0d, 0.0d); } graphView.getGraphViewStyle().setNumVerticalLabels(4); graphView.getGraphViewStyle().setNumHorizontalLabels(0); // AUTO graphView.getGraphViewStyle().setTextSize(17f); graphView.getGraphViewStyle().setVerticalLabelsAlign(Align.CENTER); graphView.getGraphViewStyle().setVerticalLabelsWidth(80); LinearLayout layout = (LinearLayout) rootView.findViewById(Rid); layout.removeAllViews(); layout.addView(graphView); rootView.postInvalidate(); }
From source file:org.mifos.androidclient.main.AccountDetailsActivity.java
private void updateContent(AbstractAccountDetails details) { if (details != null) { mDetails = details;//w ww . j a v a 2 s . com ViewBuilderFactory factory = new ViewBuilderFactory(this); AccountDetailsViewBuilder builder = factory.createAccountDetailsViewBuilder(details); LinearLayout tabContent = (LinearLayout) findViewById(R.id.account_overview); if (tabContent.getChildCount() > 0) { tabContent.removeAllViews(); } tabContent.addView(builder.buildOverviewView()); tabContent = (LinearLayout) findViewById(R.id.account_transaction); if (tabContent.getChildCount() > 0) { tabContent.removeAllViews(); } tabContent.addView(builder.buildTransactionView()); tabContent = (LinearLayout) findViewById(R.id.account_details); if (tabContent.getChildCount() > 0) { tabContent.removeAllViews(); } tabContent.addView(builder.buildDetailsView()); if (details.getClass() == SavingsAccountDetails.class) { if (((SavingsAccountDetails) details).getDepositTypeName() .equals(SavingsAccountDetails.MANDATORY_DEPOSIT)) { Button depositDueButton = (Button) findViewById(R.id.view_depositDueDetails_button); depositDueButton.setVisibility(View.VISIBLE); } } } }
From source file:com.fullmeadalchemist.mustwatch.ui.batch.detail.BatchDetailFragment.java
private void updateIngredientUiInfo() { if (viewModel.batch.ingredients != null) { // FIXME: this is not performant and looks ghetto. Timber.d("Found %s BatchIngredients for this Batch; adding them to the ingredientsList", viewModel.batch.ingredients.size()); LinearLayout ingredientsList = getActivity().findViewById(R.id.ingredients_list); ingredientsList.removeAllViews(); for (BatchIngredient ingredient : viewModel.batch.ingredients) { BatchIngredientView ingredientText = new BatchIngredientView(getActivity()); ingredientText.setBatchIngredient(ingredient); ingredientsList.addView(ingredientText); }/*from w w w . j a v a2s. co m*/ } else { Timber.d("No Ingredients found for this Recipe."); } }
From source file:com.ekuater.labelchat.ui.fragment.userInfo.HeaderFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final Activity activity = getActivity(); assert activity != null; mFrameLayout = new FrameLayout(activity); mCover = onCoverView(inflater, mFrameLayout); mHeader = onCreateHeaderView(inflater, mFrameLayout); mHeaderHeader = mHeader.findViewById(android.R.id.title); mHeaderBackground = mHeader.findViewById(android.R.id.background); assert mHeader.getLayoutParams() != null; mHeaderHeight = mHeader.getLayoutParams().height; mFakeHeader = new Space(activity); mFakeHeader.setLayoutParams(new ListView.LayoutParams(0, mHeaderHeight)); View content = onCreateContentView(inflater, mFrameLayout); if (content instanceof RelativeLayout) { isListViewEmpty = true;//from ww w. ja va 2s . c om final ListView listView = (ListView) content.findViewById(R.id.list); listView.addHeaderView(mFakeHeader); listView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView absListView, int scrollState) { if (mOnScrollListener != null) { mOnScrollListener.onScrollStateChanged(absListView, scrollState); } } @Override public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (mOnScrollListener != null) { mOnScrollListener.onScroll(absListView, firstVisibleItem, visibleItemCount, totalItemCount); } if (isListViewEmpty) { scrollHeaderTo(0); } else { final View child = absListView.getChildAt(0); assert child != null; scrollHeaderTo(child == mFakeHeader ? child.getTop() : -mHeaderHeight); } } }); } else { // Merge fake header view and content view. final LinearLayout view = new LinearLayout(activity); view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); view.setOrientation(LinearLayout.VERTICAL); view.addView(mFakeHeader); view.addView(content); // Put merged content to ScrollView final NotifyingScrollView scrollView = new NotifyingScrollView(activity); scrollView.addView(view); scrollView.setOnScrollChangedListener(new NotifyingScrollView.OnScrollChangedListener() { @Override public void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt) { scrollHeaderTo(-t); } }); content = scrollView; } mFrameLayout.addView(content); mFrameLayout.addView(mHeader); if (mCover != null) { mFrameLayout.addView(mCover); } // Post initial scroll mFrameLayout.post(new Runnable() { @Override public void run() { scrollHeaderTo(0, true); } }); return mFrameLayout; }
From source file:com.azure.webapi.LoginManager.java
/** * Creates the UI for the interactive authentication process * /*from w w w.j av a 2 s .c o m*/ * @param provider * The provider used for the authentication process * @param startUrl * The initial URL for the authentication process * @param endUrl * The final URL for the authentication process * @param context * The context used to create the authentication dialog * @param callback * Callback to invoke when the authentication process finishes */ protected void showLoginUI(MobileServiceAuthenticationProvider provider, final String startUrl, final String endUrl, final Context context, LoginUIOperationCallback callback) { if (startUrl == null || startUrl == "") { throw new IllegalArgumentException("startUrl can not be null or empty"); } if (endUrl == null || endUrl == "") { throw new IllegalArgumentException("endUrl can not be null or empty"); } if (context == null) { throw new IllegalArgumentException("context can not be null"); } final LoginUIOperationCallback externalCallback = callback; final AlertDialog.Builder builder = new AlertDialog.Builder(context); // Create the Web View to show the login page final WebView wv = new WebView(context); builder.setTitle("Connecting to a service"); builder.setCancelable(true); builder.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { if (externalCallback != null) { externalCallback.onCompleted(null, new MobileServiceException("User Canceled")); } } }); // Set cancel button's action builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (externalCallback != null) { externalCallback.onCompleted(null, new MobileServiceException("User Canceled")); } wv.destroy(); } }); wv.getSettings().setJavaScriptEnabled(true); wv.requestFocus(View.FOCUS_DOWN); wv.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { int action = event.getAction(); if (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_UP) { if (!view.hasFocus()) { view.requestFocus(); } } return false; } }); // Create a LinearLayout and add the WebView to the Layout LinearLayout layout = new LinearLayout(context); layout.setOrientation(LinearLayout.VERTICAL); layout.addView(wv); // Add a dummy EditText to the layout as a workaround for a bug // that prevents showing the keyboard for the WebView on some devices EditText dummyEditText = new EditText(context); dummyEditText.setVisibility(View.GONE); layout.addView(dummyEditText); // Add the layout to the dialog builder.setView(layout); final AlertDialog dialog = builder.create(); wv.setWebViewClient(new WebViewClient() { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { // If the URL of the started page matches with the final URL // format, the login process finished if (isFinalUrl(url)) { if (externalCallback != null) { externalCallback.onCompleted(url, null); } dialog.dismiss(); } super.onPageStarted(view, url, favicon); } // Checks if the given URL matches with the final URL's format private boolean isFinalUrl(String url) { if (url == null) { return false; } return url.startsWith(endUrl); } // Checks if the given URL matches with the start URL's format private boolean isStartUrl(String url) { if (url == null) { return false; } return url.startsWith(startUrl); } @Override public void onPageFinished(WebView view, String url) { if (isStartUrl(url)) { if (externalCallback != null) { externalCallback.onCompleted(null, new MobileServiceException( "Logging in with the selected authentication provider is not enabled")); } dialog.dismiss(); } } }); wv.loadUrl(startUrl); dialog.show(); }
From source file:com.kaliturin.blacklist.fragments.SMSSendFragment.java
private boolean addRowToContactsList(@NonNull String number, @NonNull String name) { View view = getView();/*from w ww .java2 s.c o m*/ if (view == null) { return false; } // add contact to the container if (!number2NameMap.containsKey(number)) { number2NameMap.put(number, name); } else { return false; } // create and add the new row final LinearLayout contactsViewList = (LinearLayout) view.findViewById(R.id.contacts_list); LayoutInflater inflater = getActivity().getLayoutInflater(); View row = inflater.inflate(R.layout.row_sms_send_contact, contactsViewList, false); row.setTag(number); contactsViewList.addView(row); // init contact's info view String text = number; if (!name.isEmpty() && !name.equals(number)) { text = name + " (" + number + ")"; } TextView textView = (TextView) row.findViewById(R.id.contact_number); textView.setText(text); // init button of removing ImageButton buttonRemove = (ImageButton) row.findViewById(R.id.button_remove); buttonRemove.setTag(row); buttonRemove.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { View row = (View) v.getTag(); String number = (String) row.getTag(); // remove contact from the container number2NameMap.remove(number); // remove row from the view-list contactsViewList.removeView(row); } }); moveScroll(); return true; }
From source file:mobisocial.musubi.objects.PictureObj.java
@Override public View createView(Context context, ViewGroup parent) { LinearLayout frame = new LinearLayout(context); frame.setLayoutParams(CommonLayouts.FULL_WIDTH); frame.setOrientation(LinearLayout.VERTICAL); ImageView imageView = new ImageView(context); imageView.setBackgroundResource(android.R.drawable.picture_frame); imageView.setPadding(6, 4, 8, 9);/*from ww w . j av a2 s .c o m*/ frame.addView(imageView); TextView textView = new TextView(context); frame.addView(textView); return frame; }
From source file:com.example.team04adventure.Controller.OnlineStoryList.java
/** * Starts a dialog box which allows the user to create a new story. * // ww w .j av a 2 s . c o m * @param view * the current view. */ public void addStory(View view) { AlertDialog.Builder adb = new AlertDialog.Builder(this); LinearLayout lila1 = new LinearLayout(this); lila1.setOrientation(1); final EditText titleinput = new EditText(this); final EditText bodyinput = new EditText(this); titleinput.setHint("Enter the Title here."); bodyinput.setHint("Enter a Synopsis here."); lila1.addView(titleinput); lila1.addView(bodyinput); adb.setView(lila1); adb.setTitle("New Story"); adb.setNegativeButton("Create", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Story story = new Story(); story.setTitle(titleinput.getText().toString()); Random rg = new Random(); int rint = rg.nextInt(100); story.setSynopsis(bodyinput.getText().toString()); story.setId(story.getTitle().replace(" ", "") + rint); story.setAuthor(MainActivity.username); story.setVersion(1); StorageManager sm = new StorageManager(getBaseContext()); sm.addStory(story); Intent intent = new Intent(OnlineStoryList.this, OnlineStoryList.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); } }); adb.setPositiveButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { return; } }); adb.show(); }