List of usage examples for android.widget LinearLayout setOrientation
public void setOrientation(@OrientationMode int orientation)
From source file:com.mk4droid.IMC_Activities.FActivity_TabHost.java
private LinearLayout make_Active_Tab(String text, Drawable dr) { LinearLayout ll = new LinearLayout(this); ll.setPadding(0, 0, 2, 1);/*from ww w . j a v a 2 s . co m*/ ll.setBackgroundColor(Color.GRAY); ll.setTag("ll"); ll.setOrientation(LinearLayout.VERTICAL); ll.setLayoutParams( new LinearLayout.LayoutParams(0, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT, 1)); //------ Text TextView tv = new TextView(this); tv.setBackgroundColor(Color.TRANSPARENT); tv.setTag("tv"); ll.addView(tv); // ------ hbar View hbar = new View(this); hbar.setTag("hbar"); hbar.setLayoutParams( new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.FILL_PARENT, 10)); ll.addView(hbar); //////////////////////////////////////// return ActivateColorize(ll, text, dr); }
From source file:com.mk4droid.IMC_Activities.FActivity_TabHost.java
private LinearLayout make_Inactive_Tab(String text, Drawable dr) { LinearLayout ll = new LinearLayout(this); ll.setPadding(0, 0, 2, 1);/* w w w . j av a2s .c o m*/ ll.setBackgroundColor(Color.GRAY); ll.setTag("ll"); ll.setOrientation(LinearLayout.VERTICAL); ll.setLayoutParams( new LinearLayout.LayoutParams(0, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT, 1)); //------ Text TextView tv = new TextView(this); tv.setBackgroundColor(Color.TRANSPARENT); tv.setTag("tv"); ll.addView(tv); // ------ hbar View hbar = new View(this); hbar.setTag("hbar"); hbar.setLayoutParams( new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.FILL_PARENT, 10)); ll.addView(hbar); ///////////////////////////////////// return InActivateColorize(ll, text, dr); }
From source file:ng.kingsley.android.widget.CollectionView.java
private View makeNewItemRow(RowComputeResult rowInfo) { LinearLayout ll = new LinearLayout(getContext()); LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); ll.setOrientation(LinearLayout.HORIZONTAL); ll.setLayoutParams(params);/*from w w w.ja v a 2s . co m*/ int i; for (i = 0; i < rowInfo.group.mDisplayCols; i++) { View view = getItemView(rowInfo, i, null, ll); LinearLayout.LayoutParams viewLayoutParams = setupLayoutParams(view); ll.addView(view, viewLayoutParams); } return ll; }
From source file:com.cmput301w15t15.travelclaimsapp.activitys.EditClaimActivity.java
/** * Function that is called when you press the add tag * /* ww w .j a v a 2 s . co m*/ * Creates a alert dialog that gives the user the option * of adding a previously added tag or entering a new tag name * * @param view */ public void addTagButton(View view) { final EditText enterTag = new EditText(this); final Spinner tagSpinner = new Spinner(this); //Linear layout that holds enterTag and tagSpinner views LinearLayout ll = new LinearLayout(this); ll.setOrientation(LinearLayout.VERTICAL); tagSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View arg1, int position, long id) { enterTag.setText(parent.getItemAtPosition(position).toString()); } @Override public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } }); enterTag.setHint("Enter tag"); AlertDialog.Builder alert = new AlertDialog.Builder(this); //get all the tags currently added to claims in application claimlist ArrayList<Tag> tags = ClaimListController.getTagList(); String t[] = new String[tags.size()]; for (int i = 0; i < tags.size(); i++) { t[i] = tags.get(i).getName(); } //create a arrayadaptor for displaying the tagSpinner view, and set it ArrayAdapter<String> tagA = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, t); tagSpinner.setAdapter(tagA); //add views to linear layout and set the Linear layout view as the alert dialog view ll.addView(tagSpinner); ll.addView(enterTag); alert.setView(ll); alert.setPositiveButton("Add", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Tag tag = new Tag(enterTag.getText().toString()); if (theClaim.getTagList().getTag(enterTag.getText().toString()) != null) { return; } ClaimListController.addTag(theClaim, tag); tagAdaptor.notifyDataSetChanged(); } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); alert.show(); }
From source file:com.cmput301w15t15.travelclaimsapp.activitys.EditClaimActivity.java
/** * Create a alert dialog for entering Destination values * /* w w w . ja v a 2 s . c o m*/ */ private void showDestinationAlert(final String dlocation, final String dreason) { final EditText enterLocation = new EditText(this); final EditText enterReason = new EditText(this); if (!dlocation.equals("")) { enterLocation.setText(dlocation); } if (!dreason.equals("")) { enterReason.setText(dreason); } enterLocation.setHint("Enter location"); enterReason.setHint("Enter reason"); LinearLayout linearLayout = new LinearLayout(this); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.addView(enterLocation); linearLayout.addView(enterReason); AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setView(linearLayout); alert.setPositiveButton("Add", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Destination dest = new Destination(enterLocation.getText().toString(), enterReason.getText().toString()); ClaimListController.addDestination(dest, theClaim); //open Map activity and make user pick a geolocation Intent intent = GeoLocationController.pickLocationIntent(EditClaimActivity.this); startActivityForResult(intent, GET_GEOLOCATION_CODE); destAdaptor.notifyDataSetChanged(); } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); alert.show(); }
From source file:fr.cph.chicago.activity.StationActivity.java
/** * Draw line/*from ww w .j a v a2s . com*/ * * @param eta * the eta */ private final void drawLine3(final Eta eta) { TrainLine line = eta.getRouteName(); Stop stop = eta.getStop(); int line3Padding = (int) getResources().getDimension(R.dimen.activity_station_stops_line3); Integer viewId = mIds.get(line.toString() + "_" + stop.getDirection().toString()); // viewId might be not there if CTA API provide wrong data if (viewId != null) { LinearLayout line3View = (LinearLayout) findViewById(viewId); Integer id = mIds.get(line.toString() + "_" + stop.getDirection().toString() + "_" + eta.getDestName()); if (id == null) { LinearLayout insideLayout = new LinearLayout(this); insideLayout.setOrientation(LinearLayout.HORIZONTAL); insideLayout.setLayoutParams(mParamsStop); int newId = Util.generateViewId(); insideLayout.setId(newId); mIds.put(line.toString() + "_" + stop.getDirection().toString() + "_" + eta.getDestName(), newId); TextView stopName = new TextView(this); stopName.setText(eta.getDestName() + ": "); stopName.setTextColor(getResources().getColor(R.color.grey)); stopName.setPadding(line3Padding, 0, 0, 0); insideLayout.addView(stopName); TextView timing = new TextView(this); timing.setText(eta.getTimeLeftDueDelay() + " "); timing.setTextColor(getResources().getColor(R.color.grey)); timing.setLines(1); timing.setEllipsize(TruncateAt.END); insideLayout.addView(timing); line3View.addView(insideLayout); } else { LinearLayout insideLayout = (LinearLayout) findViewById(id); TextView timing = (TextView) insideLayout.getChildAt(1); timing.setText(timing.getText() + eta.getTimeLeftDueDelay() + " "); } line3View.setVisibility(View.VISIBLE); } }
From source file:de.tobiasbielefeld.solitaire.ui.HighScores.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //initialize stuff setContentView(R.layout.activity_high_scores); ActionBar actionBar = getSupportActionBar(); layoutScores = (LinearLayout) findViewById(R.id.highScoresLinearLayout1); //load the layouts and textView textWonGames = (TextView) findViewById(R.id.highScoresTextViewGamesWon); textWinPercentage = (TextView) findViewById(R.id.highScoresTextViewWinPercentage); mAdView = (AdView) findViewById(R.id.adView2); AdRequest adRequest = new AdRequest.Builder().build(); mAdView.loadAd(adRequest);/*from ww w .j a v a2 s. co m*/ if (actionBar != null) //set a nice back arrow in the actionBar actionBar.setDisplayHomeAsUpEnabled(true); loadStatistics(); for (int i = 0; i < Scores.MAX_SAVED_SCORES; i++) { //for each entry in highScores, add a new view with it if (scores.get(i, 0) == 0) //if the score is zero, don't show it continue; final LinearLayout linearLayout2 = new LinearLayout(this); //new layout for the entry LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( //create new layout params LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);// params.setMargins(0, 0, 0, 10); //add some padding linearLayout2.setLayoutParams(params); //and apply them linearLayout2.setGravity(Gravity.CENTER); //set gravity linearLayout2.setOrientation(LinearLayout.HORIZONTAL); //also set orientation TextView textView = new TextView(this); //new textView for the score of the entry textView.setText(String.format(Locale.getDefault(), "%s. %s %s ", i + 1, getString( //add the score R.string.game_score), scores.get(i, 0))); textView.setTextSize(20); //and set text size TextView textView2 = new TextView(this); //new textView for the time of the entry textView2.setText(String.format(Locale.getDefault(), "%s %02d:%02d:%02d", //add it to the view getString(R.string.game_time), scores.get(i, 1) / 3600, (scores.get(i, 1) % 3600) / 60, (scores.get(i, 1) % 60))); textView2.setTextSize(20); //set size linearLayout2.addView(textView); //now add both textViews to the entry layout linearLayout2.addView(textView2); layoutScores.addView(linearLayout2); //and finally add the new entry layout to the scores layout } }
From source file:com.example.appf.CS3570.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent();//from w w w .jav a 2s . c om Bundle extras = intent.getExtras(); cam = false; // Just in case we are coming from the ServerActivity if (extras != null) { if (extras.containsKey("server_name")) SERVER_IP = extras.getString("server_name"); if (extras.containsKey("server_port")) SERVERPORT = Integer.parseInt(extras.getString("server_port")); } filter = new IMUfilter(.1f, 5); filter.reset(); // Set up reset button Button b = new Button(this); b.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { filter.reset(); } }); b.setText("Reset"); // Set up camera mode. Are we going to use this? Button c = new Button(this); c.setText("Camera Mode"); c.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { filter.reset(); mGLView.mRenderer.mCamera = new Camera(); cam = !cam; } }); LinearLayout ll = new LinearLayout(this); ll.setOrientation(LinearLayout.VERTICAL); ll.setBackgroundColor(Color.parseColor("#21C9FF")); ll.addView(b); ll.addView(c); // Create a GLSurfaceView instance and set it // as the ContentView for this Activity mGLView = new MyGLSurfaceView(this, this); ll.addView(mGLView); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); gyroscope = mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE); accelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); magnetometer = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD); setContentView(ll); new Thread(new SocketThread()).start(); }
From source file:com.uzmap.pkg.uzmodules.uzBMap.mode.Billboard.java
private LinearLayout titleLayout() { LinearLayout titleLayout = new LinearLayout(context); LayoutParams layoutParams = new LayoutParams(UZCoreUtil.dipToPix(width - iconSize - 30), UZCoreUtil.dipToPix(height)); layoutParams.setMargins(UZCoreUtil.dipToPix(10), 0, UZCoreUtil.dipToPix(10), 0); titleLayout.setLayoutParams(layoutParams); titleLayout.setOrientation(LinearLayout.VERTICAL); LinearLayout titleLayout2 = new LinearLayout(context); LayoutParams layoutParams2 = new LayoutParams(UZCoreUtil.dipToPix(width - iconSize - 30), UZCoreUtil.dipToPix(height - 10)); titleLayout2.setGravity(Gravity.CENTER_VERTICAL); titleLayout2.setOrientation(LinearLayout.VERTICAL); titleLayout2.setLayoutParams(layoutParams2); titleLayout.addView(titleLayout2);//from www .j a v a2s . c o m titleLayout2.addView(title()); titleLayout2.addView(subTitle()); return titleLayout; }
From source file:it.redturtle.mobile.apparpav.MeteogramAdapter.java
/** * DOUBLE TITLE ROW/*from w ww . ja va2s.c om*/ * @param att * @param linear * @return */ public LinearLayout getDoubleTitleRow(Map<String, String> att, LinearLayout linear) { LinearLayout container_layout = new LinearLayout(context); container_layout.setMinimumHeight(30); container_layout .setBackgroundDrawable(context.getResources().getDrawable(R.drawable.view_shape_meteo_blue)); container_layout.setVerticalGravity(Gravity.CENTER); container_layout.setOrientation(LinearLayout.HORIZONTAL); LinearLayout.LayoutParams value_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 0.3f); TextView tx = new TextView(context); tx.setText(""); tx.setTextColor(Color.rgb(66, 66, 66)); container_layout.addView(tx, value_params); LinearLayout.LayoutParams ltext1 = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 0.35f); TextView t1 = new TextView(context); t1.setText(att.get("value1")); t1.setTextSize(11); t1.setGravity(Gravity.CENTER_HORIZONTAL); t1.setPadding(2, 0, 0, 2); t1.setTextColor(Color.rgb(255, 255, 255)); container_layout.addView(t1, ltext1); LinearLayout.LayoutParams ltext2 = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 0.35f); TextView t2 = new TextView(context); t2.setText(att.get("value2")); t2.setTextSize(11); t2.setGravity(Gravity.CENTER_HORIZONTAL); t2.setPadding(2, 0, 0, 2); t2.setTextColor(Color.rgb(255, 255, 255)); container_layout.addView(t2, ltext2); linear.addView(container_layout); return linear; }