List of usage examples for android.widget LinearLayout addView
public void addView(View child)
Adds a child view.
From source file:com.cerema.cloud2.ui.dialog.CredentialsDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Create field for username mUsernameET = new EditText(getActivity()); mUsernameET.setHint(getActivity().getText(R.string.auth_username)); // Create field for password mPasswordET = new EditText(getActivity()); mPasswordET.setHint(getActivity().getText(R.string.auth_password)); mPasswordET.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); // Prepare LinearLayout for dialog LinearLayout ll = new LinearLayout(getActivity()); ll.setOrientation(LinearLayout.VERTICAL); ll.addView(mUsernameET); ll.addView(mPasswordET);//from w w w. j av a 2 s.com ll.requestFocus(); setRetainInstance(true); Builder authDialog = new AlertDialog.Builder(getActivity()) .setTitle(getActivity().getText(R.string.saml_authentication_required_text)).setView(ll) .setCancelable(false).setPositiveButton(R.string.common_ok, this) .setNegativeButton(R.string.common_cancel, this); Dialog d = authDialog.create(); d.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE); return d; }
From source file:com.anjlu.weighttracker.chart.LineFragment.java
private void compose(View v) { // init example series data Cursor cursor = getActivity().getContentResolver().query(WeightProvider.CONTENT_URI_WEIGHT, null, WeightProvider.WeightTracker.DATE_TRACK + " <= ?", new String[] { Utils.formatDate(Calendar.getInstance().getTime()) }, WeightProvider.WeightTracker._ID); int i = 0;//from ww w . ja va 2 s . co m Vector<GraphViewData> values = new Vector<GraphViewData>(); while (cursor.moveToNext()) { String dateTrack = cursor.getString(cursor.getColumnIndex(WeightProvider.WeightTracker.DATE_TRACK)); String weight = cursor.getString(cursor.getColumnIndex(WeightProvider.WeightTracker.WEIGHT)); Log.i(LineFragment.class.getCanonicalName(), "Date: " + dateTrack + "Weight: " + weight); values.add(new GraphViewData(i++, Double.parseDouble(weight))); } GraphViewData[] graphs = {}; graphs = values.toArray((GraphViewData[]) graphs); GraphViewSeries exampleSeries = new GraphViewSeries(graphs); GraphView graphView = new LineGraphView(getActivity() // context , "GraphViewDemo" // heading ); graphView.getGraphViewStyle().setNumHorizontalLabels(graphs.length); graphView.getGraphViewStyle().setGridColor(Color.WHITE); graphView.addSeries(exampleSeries); // data LinearLayout layout = (LinearLayout) v.findViewById(R.id.graph1); layout.addView(graphView); }
From source file:com.aqnote.app.wifianalyzer.wifi.graph.channel.ChannelGraphFragment.java
private void addGraphNavigation(View view, ChannelGraphNavigation channelGraphNavigation) { LinearLayout linearLayout = (LinearLayout) view.findViewById(R.id.graphNavigation); for (NavigationItem navigationItem : channelGraphNavigation.getNavigationItems()) { linearLayout.addView(navigationItem.getButton()); }// w w w . j a v a 2 s .c o m }
From source file:com.alibaba.akita.samples.TestFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if ((savedInstanceState != null) && savedInstanceState.containsKey(KEY_CONTENT)) { mContent = savedInstanceState.getString(KEY_CONTENT); }/*from w w w . j a v a 2s . co m*/ TextView text = new TextView(getActivity()); text.setGravity(Gravity.CENTER); text.setText(mContent); text.setTextSize(20 * getResources().getDisplayMetrics().density); text.setPadding(20, 20, 20, 20); LinearLayout layout = new LinearLayout(getActivity()); layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); layout.setGravity(Gravity.CENTER); layout.addView(text); return layout; }
From source file:com.pansapiens.occyd.MapResults.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // receive search results from calling Activity, // as a raw json string Bundle incoming_data = getIntent().getExtras(); String json_txt = null;/*ww w .j ava 2 s. co m*/ ArrayList<Post> post_results = new ArrayList(); if (incoming_data != null) { json_txt = incoming_data.getString("json"); try { post_results = JSONdecoder.json2postArray(json_txt); } catch (JSONException e) { Toast.makeText(MapResults.this, "FAIL: Malformed response from server.", Toast.LENGTH_LONG).show(); } } setContentView(R.layout.mapview); map = (MapView) findViewById(R.id.map); // zoom controls are placed in their own 'sub-layout' called // "@+id/zoom" in the mapview.xml layout. // this ensures they are correctly positioned, don't scroll offscreen // and don't prevent touch scrolling of the map when visible LinearLayout zoomView = (LinearLayout) findViewById(R.id.zoom); zoomView.addView(map.getZoomControls()); // (straight out of the MapViewCompassDemo.java API Demos) // put a dot on our current location once we have a fix mMyLocationOverlay = new MyLocationOverlay(this, map); mMyLocationOverlay.runOnFirstFix(new Runnable() { public void run() { map.getController().animateTo(mMyLocationOverlay.getMyLocation()); } }); map.getOverlays().add(mMyLocationOverlay); map.getController().setZoom(17); locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); LocationUpdater locupdater = new LocationUpdater(locationManager, this); locupdater.startUpdating(); // add markers for search results // marker from: http://commons.wikimedia.org/wiki/File:Map_symbol_location_02.png Drawable marker = getResources().getDrawable(R.drawable.marker); marker.setBounds(0, 0, marker.getIntrinsicWidth(), marker.getIntrinsicHeight()); map.getOverlays().add(new MapResultsOverlay(marker, post_results)); //map.getOverlays().add(new MapResultsOverlay(marker)); // dummy testing constructor .... }
From source file:au.com.cybersearch2.classyfy.MainActivity.java
/** * Display content - Heading and list of top categories * @param nodeDetails Bean containing details to be displayed *///from ww w .j a v a2s .c o m protected void displayContent(NodeDetailsBean nodeDetails) { View categoryDetails = ViewHelper.createRecordView(this, nodeDetails.getHeading(), nodeDetails.getCategoryTitles(), true, new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent viewIntent = new Intent(MainActivity.this, TitleSearchResultsActivity.class); viewIntent.setData( Uri.withAppendedPath(ClassyFySearchEngine.CONTENT_URI, String.valueOf(id))); viewIntent.setAction(Intent.ACTION_VIEW); startActivity(viewIntent); finish(); } }); LinearLayout categoryLayout = (LinearLayout) findViewById(R.id.top_category); categoryLayout.addView(categoryDetails); }
From source file:com.jeffreyawest.weblogic.monitor.activity.display.DisplayClusterActivity.java
@Override public void updateDisplay(Cluster result) { setTitle(result.getName());/*from w ww . java 2 s . c o m*/ super.updateDisplay(result); FragmentManager fm = getSupportFragmentManager(); ClusterServerHealthPieChart healthPieChart = (ClusterServerHealthPieChart) fm .findFragmentById(R.id.server_health_chart_fragment); if (healthPieChart != null) healthPieChart.update(result); ClusterServerStatePieChart statePieChart = (ClusterServerStatePieChart) fm .findFragmentById(R.id.server_state_chart_fragment); if (statePieChart != null) statePieChart.update(result); LinearLayout tableContainer = (LinearLayout) DisplayClusterActivity.this.findViewById(R.id.data_container); TableLayout summaryTable = new TableLayout(DisplayClusterActivity.this); tableContainer.addView(summaryTable); summaryTable.addView(getRow(R.string.cluster_name, result.getName())); for (ClusterServer server : result.getServers()) { tableContainer.addView(getSeparatorRow()); tableContainer.addView(getServerTable(server)); } }
From source file:com.example.android.supportv7.util.DiffUtilActivity.java
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); LinearLayout ll = new LinearLayout(this); RecyclerView rv = new RecyclerView(this); Button shuffle = new Button(this); shuffle.setText("Shuffle"); ll.addView(shuffle); ll.addView(rv);/*www . java2 s .co m*/ rv.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); rv.setLayoutManager(new LinearLayoutManager(this)); List<String> cheeseList = createRandomCheeseList(Collections.<String>emptyList(), 50); final SimpleStringAdapter adapter = new SimpleStringAdapter(this, cheeseList.toArray(new String[cheeseList.size()])); rv.setAdapter(adapter); final AtomicBoolean refreshingList = new AtomicBoolean(false); shuffle.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (refreshingList.getAndSet(true)) { // already refreshing, do not allow modifications return; } //noinspection unchecked new AsyncTask<List<String>, Void, Pair<List<String>, DiffUtil.DiffResult>>() { @Override protected Pair<List<String>, DiffUtil.DiffResult> doInBackground(List<String>... lists) { List<String> oldList = lists[0]; List<String> newList = createRandomCheeseList(oldList, 5); DiffUtil.DiffResult diffResult = DiffUtil.calculateDiff(new MyCallback(oldList, newList)); //noinspection unchecked return new Pair(newList, diffResult); } @Override protected void onPostExecute(Pair<List<String>, DiffUtil.DiffResult> resultPair) { refreshingList.set(false); adapter.setValues(resultPair.first); resultPair.second.dispatchUpdatesTo(adapter); Toast.makeText(DiffUtilActivity.this, "new list size " + resultPair.first.size(), Toast.LENGTH_SHORT).show(); } }.execute(adapter.getValues()); } }); setContentView(ll); }
From source file:com.sintech.RunningBus.java
public void initBusStation() { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); String linename = sp.getString("lastLine", ""); if (linename.equals("")) { Log.d("DBG", "initBusStation no line"); return;//w w w.ja v a2s. com } String js = sp.getString(linename, "{'name':'" + linename + "','stations':[],'stationDn':[]}"); try { JSONObject jsonObject = new JSONObject(js); JSONArray array = jsonObject.getJSONArray("stations"); TextView busname = (TextView) findViewById(R.id.IdBusname); busname.setText(jsonObject.getString("name")); LinearLayout ll = (LinearLayout) findViewById(R.id.IdStations); for (int i = 0; i < array.length(); i++) { String stInfo = array.getString(i); TextView station = new TextView(this); station.setText(stInfo.split("=")[0]); ll.addView(station); } } catch (Exception e) { } }
From source file:com.example.android.commitcontent.app.ImageKeyboard.java
@Override public View onCreateInputView() { mGifButton = new Button(this); mGifButton.setText("Insert GIF"); mGifButton.setOnClickListener(new View.OnClickListener() { @Override/*from w w w. j ava 2s . c o m*/ public void onClick(View view) { ImageKeyboard.this.doCommitContent("A waving flag", MIME_TYPE_GIF, mGifFile); } }); mPngButton = new Button(this); mPngButton.setText("Insert PNG"); mPngButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { ImageKeyboard.this.doCommitContent("A droid logo", MIME_TYPE_PNG, mPngFile); } }); mWebpButton = new Button(this); mWebpButton.setText("Insert WebP"); mWebpButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { ImageKeyboard.this.doCommitContent("Android N recovery animation", MIME_TYPE_WEBP, mWebpFile); } }); final LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); layout.addView(mGifButton); layout.addView(mPngButton); layout.addView(mWebpButton); return layout; }