List of usage examples for android.widget LinearLayout setLayoutParams
public void setLayoutParams(ViewGroup.LayoutParams params)
From source file:gr.ioanpier.auth.users.memorypaintings.MainActivityFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { //Language Locale String languageToLoad = getActivity().getIntent().getStringExtra(LANGUAGE); // your language if (languageToLoad != null) { Locale locale = new Locale(languageToLoad); Locale.setDefault(locale); Configuration config = new Configuration(); config.locale = locale;/* w w w .jav a 2 s . c o m*/ getActivity().getResources().updateConfiguration(config, getActivity().getResources().getDisplayMetrics()); } View rootView = inflater.inflate(R.layout.fragment_main, container, false); //Calculate the level and the number of cards. level = getActivity().getIntent().getIntExtra(LEVEL_TAG, 0); if (level >= layoutsPerLevel.length) level = layoutsPerLevel.length - 1; numberOfCards = cardsPerLevel[level]; numberOfBitmapWorkerTasks = numberOfCards / 2; instantiateLoadingBar(); if (!isExternalStorageReadable()) { Log.e(LOG, "External storage wasn't readable"); storedDrawables = null; } else { File[] imageFiles = getFilesFromDirectory(WelcomeScreen.IMAGES_PATH, ".jpg", ".png"); if (imageFiles.length > 0) { String descriptionsFolder = "Descriptions"; Locale locale = getActivity().getResources().getConfiguration().locale; if (locale.getDisplayLanguage().equals(Locale.ENGLISH.getDisplayLanguage())) descriptionsFolder = descriptionsFolder.concat("_en"); else descriptionsFolder = descriptionsFolder.concat("_pl"); File[] descFiles = getFilesFromDirectory(WelcomeScreen.DESCRIPTIONS_PATH, ".txt"); //getDrawables storedDrawables = getDrawables(imageFiles, descFiles); } else { Log.e(LOG, "No files found in external storage"); storedDrawables = null; } } pairs = new int[numberOfCards]; for (int i = 0; i < numberOfCards; i++) { pairs[i] = -1; } cards = new ImageViewCard[numberOfCards]; //This is where the layout magic happens. LinearLayout linearLayout; int index; for (int i = 0; i < layoutsPerLevel[level]; i++) { //The layout consists of multiple vertical LinearLayout[s] positioned horizontally next to each other. linearLayout = new LinearLayout(getActivity()); linearLayout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT, 1.0f)); linearLayout.setOrientation(LinearLayout.VERTICAL); for (int j = 0; j < numberOfCards / layoutsPerLevel[level]; j++) { //Each LinearLayout has a number of ImageViewCard[s], each positioned evenly in inside the layout. The number depends on the level. //ImageViewCard is an extension of the ViewFlipper class with a built in flipCard method for flipping between 2 images and which also includes animation. ImageViewCard card = new ImageViewCard(getActivity()); card.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 1.0f)); ((LinearLayout.LayoutParams) card.getLayoutParams()).setMargins(16, 16, 16, 16); //SquareImageView is an extension of the ImageView class that ensures that the image is square. //Two are needed, one for the back of the image and one for the front. SquareImageView image1 = new SquareImageView(getActivity()); image1.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); SquareImageView image2 = new SquareImageView(getActivity()); image2.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); //Add the SquareImageView[s] to the ImageViewCard and subsequently that to the LinearLayout. card.addView(image1); card.addView(image2); index = i * numberOfCards / layoutsPerLevel[level] + j; linearLayout.addView(card); cardsIndex.put(card.hashCode(), index); //Set the back of the image. ((ImageView) card.getChildAt(0)) .setImageDrawable(ContextCompat.getDrawable(getActivity(), R.drawable.black)); //Save the ImageViewCard for later use. cards[index] = card; } //Add the LinearLayout to the rootView. ((LinearLayout) rootView.findViewById(R.id.parent)).addView(linearLayout); } //Assign a listener for every ImageViewCard. View.OnClickListener onClickListener = new View.OnClickListener() { @Override public void onClick(View view) { if (!stillAnimating && numberOfBitmapWorkerTasks == 0) { int cardID = cardsIndex.get(view.hashCode()); stillAnimating = true; synchronized (gameLogicLock) { if (numberOfCardsFound < numberOfCards) onCardFlipped(cardID); else onCardClicked(cardID); } //Add a delay before the listener can be activated again. new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... voids) { try { Thread.sleep(250); } catch (InterruptedException e) { } return null; } @Override protected void onPostExecute(Void n) { stillAnimating = false; } }.execute(); } else if (numberOfBitmapWorkerTasks > 0) { Toast.makeText(getActivity(), getString(R.string.loading_bar_message), Toast.LENGTH_SHORT) .show(); } } }; for (int i = 0; i < numberOfCards; i++) { cards[i].setOnClickListener(onClickListener); } //Initialize found = new boolean[numberOfCards]; for (int i = 0; i < numberOfCards; i++) found[i] = false; //Initialize int[] chosenDrawables = new int[numberOfCards / 2]; cardDrawablePairs = new int[numberOfCards]; //Initialize. Holds the index of every ImageViewCard in cards. Will later be used for the pairs. ArrayList<Integer> availablePairs = new ArrayList<>(); for (int i = 0; i < numberOfCards; i++) availablePairs.add(i); Collections.shuffle(availablePairs); Random r = new Random(); int pair1, pair2; BitmapWorkerTask bitmapWorkerTask; for (int i = 0; i < numberOfCards / 2; i++) { //Choose at random one of the available images. Make sure it's unique. int range; if (storedDrawables == null) range = colors.length; else range = storedDrawables.length; boolean unique = false; while (!unique) { unique = true; //If there are a lot of images, this should be changed (there will never be a lot) chosenDrawables[i] = r.nextInt(range); for (int j = 0; j < i; j++) { if (chosenDrawables[i] == chosenDrawables[j]) unique = false; } } //availablePairs have already been shuffled, so just remove the first 2. pair1 = availablePairs.remove(0); pair2 = availablePairs.remove(0); cardDrawablePairs[pair1] = chosenDrawables[i]; cardDrawablePairs[pair2] = chosenDrawables[i]; //Assign the front of the ImageViewCard to the randomly chosen Drawable. ImageView imageView1, imageView2; String absolutePath; if (storedDrawables == null) { (cards[pair1].getChildAt(1)) .setBackgroundColor(ContextCompat.getColor(getActivity(), colors[chosenDrawables[i]])); (cards[pair2].getChildAt(1)) .setBackgroundColor(ContextCompat.getColor(getActivity(), colors[chosenDrawables[i]])); } else { DisplayMetrics displayMetrics = new DisplayMetrics(); WindowManager wm = (WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE); // the results will be higher than using the activity context object or the getWindowManager() shortcut wm.getDefaultDisplay().getMetrics(displayMetrics); int screenWidth = displayMetrics.widthPixels / (layoutsPerLevel[level]); int screenHeight = displayMetrics.heightPixels / (cardsPerLevel[level] / layoutsPerLevel[level]); absolutePath = storedDrawables[chosenDrawables[i]].absolute_path_image; imageView1 = ((ImageView) cards[pair1].getChildAt(1)); imageView2 = ((ImageView) cards[pair2].getChildAt(1)); bitmapWorkerTask = new BitmapWorkerTask(screenWidth, screenHeight, imageView1, imageView2); bitmapWorkerTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, absolutePath); } //Save the pairs. pairs[pair1] = pair2; pairs[pair2] = pair1; } if (storedDrawables == null) { numberOfBitmapWorkerTasks = 0; } return rootView; }
From source file:com.mediaexplorer.remote.MexRemoteActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);/*ww w. j av a 2 s . c om*/ this.setTitle(R.string.app_name); dbg = "MexWebremote"; text_view = (TextView) findViewById(R.id.text); web_view = (WebView) findViewById(R.id.link_view); web_view.getSettings().setJavaScriptEnabled(true);/* /* Future: setOverScrollMode is API level >8 * web_view.setOverScrollMode (OVER_SCROLL_NEVER); */ web_view.setBackgroundColor(0); web_view.setWebViewClient(new WebViewClient() { /* for some reason we only get critical errors so an auth error * is not handled here which is why there is some crack that test * the connection with a special httpclient */ @Override public void onReceivedHttpAuthRequest(final WebView view, final HttpAuthHandler handler, final String host, final String realm) { String[] userpass = new String[2]; userpass = view.getHttpAuthUsernamePassword(host, realm); HttpResponse response = null; HttpGet httpget; DefaultHttpClient httpclient; String target_host; int target_port; target_host = MexRemoteActivity.this.target_host; target_port = MexRemoteActivity.this.target_port; /* We may get null from getHttpAuthUsernamePassword which will * break the setCredentials so junk used instead to keep * it happy. */ Log.d(dbg, "using the set httpauth, testing auth using client"); try { if (userpass == null) { userpass = new String[2]; userpass[0] = "none"; userpass[1] = "none"; } } catch (Exception e) { userpass = new String[2]; userpass[0] = "none"; userpass[1] = "none"; } /* Log.d ("debug", * "trying: GET http://"+userpass[0]+":"+userpass[1]+"@"+target_host+":"+target_port+"/"); */ /* We're going to test the authentication credentials that we * have before using them so that we can act on the response. */ httpclient = new DefaultHttpClient(); httpget = new HttpGet("http://" + target_host + ":" + target_port + "/"); httpclient.getCredentialsProvider().setCredentials(new AuthScope(target_host, target_port), new UsernamePasswordCredentials(userpass[0], userpass[1])); try { response = httpclient.execute(httpget); } catch (IOException e) { Log.d(dbg, "Problem executing the http get"); e.printStackTrace(); } Log.d(dbg, "HTTP reponse:" + Integer.toString(response.getStatusLine().getStatusCode())); if (response.getStatusLine().getStatusCode() == 401) { /* We got Authentication failed (401) so ask user for u/p */ /* login dialog box */ final AlertDialog.Builder logindialog; final EditText user; final EditText pass; LinearLayout layout; LayoutParams params; TextView label_username; TextView label_password; logindialog = new AlertDialog.Builder(MexRemoteActivity.this); logindialog.setTitle("Mex Webremote login"); user = new EditText(MexRemoteActivity.this); pass = new EditText(MexRemoteActivity.this); layout = new LinearLayout(MexRemoteActivity.this); pass.setTransformationMethod(new PasswordTransformationMethod()); layout.setOrientation(LinearLayout.VERTICAL); params = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); layout.setLayoutParams(params); user.setLayoutParams(params); pass.setLayoutParams(params); label_username = new TextView(MexRemoteActivity.this); label_password = new TextView(MexRemoteActivity.this); label_username.setText("Username:"); label_password.setText("Password:"); layout.addView(label_username); layout.addView(user); layout.addView(label_password); layout.addView(pass); logindialog.setView(layout); logindialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); logindialog.setPositiveButton("Login", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String uvalue = user.getText().toString().trim(); String pvalue = pass.getText().toString().trim(); view.setHttpAuthUsernamePassword(host, realm, uvalue, pvalue); handler.proceed(uvalue, pvalue); } }); logindialog.show(); /* End login dialog box */ } else /* We didn't get a 401 */ { handler.proceed(userpass[0], userpass[1]); } } /* End onReceivedHttpAuthRequest */ }); /* End Override */ /* Run mdns to check for service in a "runnable" (async) */ handler.post(new Runnable() { public void run() { startMdns(); } }); dialog = ProgressDialog.show(MexRemoteActivity.this, "", "Searching...", true); /* Let's put something in the webview while we're waiting */ String summary = "<html><head><style>body { background-color: #000000; color: #ffffff; }></style></head><body><p>Searching for the media explorer webservice</p><p>More infomation on <a href=\"http://media-explorer.github.com\" >Media Explorer's home page</a></p></body></html>"; web_view.loadData(summary, "text/html", "utf-8"); }
From source file:com.adarshahd.indianrailinfo.donate.TrainDetails.java
private void createTableLayoutTrainFare() { if (mPage.contains("SORRY")) { TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText("Not a valid class, Please select a different class and try again."); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); textViewTrnDtls.setTextColor(Color.RED); mFrameLayout.removeAllViews();/* w ww .ja va 2s.com*/ mFrameLayout.addView(textViewTrnDtls); if (mDialog.isShowing()) { mDialog.cancel(); } return; } if (mPage.contains("ISL Of")) { TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText("Station is not in ISL Of the Train. \nPlease modify the source/destination!"); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); textViewTrnDtls.setTextColor(Color.RED); mFrameLayout.removeAllViews(); mFrameLayout.addView(textViewTrnDtls); if (mDialog.isShowing()) { mDialog.cancel(); } return; } if (mPage.contains("ERROR")) { TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText("Your request resulted in an error.\nPlease check!"); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); textViewTrnDtls.setTextColor(Color.RED); mFrameLayout.removeAllViews(); mFrameLayout.addView(textViewTrnDtls); if (mDialog.isShowing()) { mDialog.cancel(); } return; } if (mPage.contains("Network Connectivity")) { TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText("Looks like the server is busy.\nPlease try later!"); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); textViewTrnDtls.setTextColor(Color.RED); mFrameLayout.removeAllViews(); mFrameLayout.addView(textViewTrnDtls); if (mDialog.isShowing()) { mDialog.cancel(); } return; } if (mPage.contains("unavailable")) { TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText( "Response from server:\n\nYour request could not be processed now. \nPlease try again later!"); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); textViewTrnDtls.setTextColor(Color.RED); mFrameLayout.removeAllViews(); mFrameLayout.addView(textViewTrnDtls); if (mDialog.isShowing()) { mDialog.cancel(); } return; } if (mDetails == null || !mDetails.getTrainNumber().equals(mTrainNumber)) { Iterator iterator = null; try { iterator = mElements.first().parent().parent().parent().getElementsByTag("tr").iterator(); } catch (Exception e) { Log.i("TrainDetails", mPage); } mListFr = new ArrayList<List<String>>(); List<String> list; Element tmp; while (iterator.hasNext()) { tmp = (Element) iterator.next(); list = new ArrayList<String>(); list.add(tmp.select("td").get(0).text()); list.add(tmp.select("td").get(1).text()); mListFr.add(list); } mDetails = new Details(mListFr, TrainEnquiry.FARE, mTrainNumber); } else { mListFr = mDetails.getList(); } mTblLayoutFr = new TableLayout(mActivity); TableRow row; TextView tv1, tv2; mTblLayoutFr.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); for (int i = 0; i < mListFr.size(); i++) { row = new TableRow(mActivity); tv1 = new TextView(mActivity); tv2 = new TextView(mActivity); tv1.setText(" " + mListFr.get(i).get(0)); tv2.setText(" " + mListFr.get(i).get(1)); tv1.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Medium); tv2.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Medium); tv1.setPadding(5, 5, 5, 5); tv2.setPadding(5, 5, 5, 5); /*tv2.setBackgroundResource(R.drawable.card_divider); tv3.setBackgroundResource(R.drawable.card_divider); tv4.setBackgroundResource(R.drawable.card_divider);*/ row.addView(tv1); row.addView(tv2); row.setBackgroundResource(R.drawable.button_selector); row.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL); mTblLayoutFr.addView(row); } LinearLayout ll = new LinearLayout(mActivity); ScrollView scrollView = new ScrollView(mActivity); TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText("Fare details:"); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); ll.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); ll.setOrientation(LinearLayout.VERTICAL); ll.addView(textViewTrnDtls); ll.addView(mTblLayoutFr); scrollView.addView(ll); mFrameLayout.removeAllViews(); mFrameLayout.addView(scrollView); if (mDialog.isShowing()) { mDialog.cancel(); } }
From source file:com.example.angelina.travelapp.map.MapFragment.java
/** * Populate the place detail contained/*from w ww .j a v a 2 s . co m*/ * within the bottom sheet * @param place - Place item selected by user */ @Override public final void showDetail(final Place place) { final TextView txtName = (TextView) mBottomSheet.findViewById(R.id.placeName); txtName.setText(place.getName()); String address = place.getAddress(); final String[] splitStrs = TextUtils.split(address, ","); if (splitStrs.length > 0) { address = splitStrs[0]; } final TextView txtAddress = (TextView) mBottomSheet.findViewById(R.id.placeAddress); txtAddress.setText(address); final TextView txtPhone = (TextView) mBottomSheet.findViewById(R.id.placePhone); txtPhone.setText(place.getPhone()); final LinearLayout linkLayout = (LinearLayout) mBottomSheet.findViewById(R.id.linkLayout); // Hide the link placeholder if no link is found if (place.getURL().isEmpty()) { linkLayout.setLayoutParams(new LinearLayoutCompat.LayoutParams(0, 0)); linkLayout.requestLayout(); } else { final int height = (int) (48 * Resources.getSystem().getDisplayMetrics().density); linkLayout.setLayoutParams( new LinearLayoutCompat.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, height)); linkLayout.requestLayout(); final TextView txtUrl = (TextView) mBottomSheet.findViewById(R.id.placeUrl); txtUrl.setText(place.getURL()); } final TextView txtType = (TextView) mBottomSheet.findViewById(R.id.placeType); txtType.setText(place.getType()); // Assign the appropriate icon final Drawable d = CategoryHelper.getDrawableForPlace(place, getActivity()); txtType.setCompoundDrawablesWithIntrinsicBounds(d, null, null, null); bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED); // Center map on selected place mPresenter.centerOnPlace(place); mShowSnackbar = false; centeredPlaceName = place.getName(); }
From source file:com.adarshahd.indianrailinfo.donate.TrainDetails.java
private void createTableLayoutTrainAvailability() { if (mPage.contains("SORRY")) { TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText("Not a valid class, Please select a different class and try again."); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); textViewTrnDtls.setTextColor(Color.RED); mFrameLayout.removeAllViews();/*from w ww .ja va2s.c o m*/ mFrameLayout.addView(textViewTrnDtls); if (mDialog.isShowing()) { mDialog.cancel(); } return; } if (mPage.contains("ISL Of")) { TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText("Station is not in ISL Of the Train. \nPlease modify the source/destination!"); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); textViewTrnDtls.setTextColor(Color.RED); mFrameLayout.removeAllViews(); mFrameLayout.addView(textViewTrnDtls); if (mDialog.isShowing()) { mDialog.cancel(); } return; } if (mPage.contains("ERROR")) { TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText("Your request resulted in an error.\nPlease check!"); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); textViewTrnDtls.setTextColor(Color.RED); mFrameLayout.removeAllViews(); mFrameLayout.addView(textViewTrnDtls); if (mDialog.isShowing()) { mDialog.cancel(); } return; } if (mPage.contains("Network Connectivity")) { TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText("Looks like the server is busy.\nPlease try later!"); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); textViewTrnDtls.setTextColor(Color.RED); mFrameLayout.removeAllViews(); mFrameLayout.addView(textViewTrnDtls); if (mDialog.isShowing()) { mDialog.cancel(); } return; } if (mPage.contains("unavailable")) { TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText( "Response from server:\n\nYour request could not be processed now.\nPlease try again later!"); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); textViewTrnDtls.setTextColor(Color.RED); mFrameLayout.removeAllViews(); mFrameLayout.addView(textViewTrnDtls); if (mDialog.isShowing()) { mDialog.cancel(); } return; } if (mDetails == null || !mDetails.getTrainNumber().equals(mTrainNumber)) { Iterator iterator = null; try { iterator = mElements.first().parent().parent().parent().getElementsByTag("tr").iterator(); } catch (Exception e) { Log.i("TrainDetails", mPage); e.printStackTrace(); return; } mListAv = new ArrayList<List<String>>(); List<String> list; Element tmp; tmp = (Element) iterator.next(); list = new ArrayList<String>(); list.add(tmp.select("th").get(0).text()); list.add("Date"); list.add(tmp.select("th").get(2).text()); //list.add(tmp.select("th").get(3).text()); mListAv.add(list); while (iterator.hasNext()) { tmp = (Element) iterator.next(); if (!tmp.hasText()) { continue; } list = new ArrayList<String>(); list.add(tmp.select("td").get(0).text()); list.add(tmp.select("td").get(1).text()); list.add(tmp.select("td").get(2).text()); //list.add(tmp.select("td").get(3).text()); mListAv.add(list); } mDetails = new Details(mListAv, TrainEnquiry.AVAILABILITY, mTrainNumber); } else { mListAv = mDetails.getList(); } mTblLayoutAv = new TableLayout(mActivity); TableRow row; TextView tv1, tv2, tv3; mTblLayoutAv.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); for (int i = 0; i < mListAv.size(); i++) { row = new TableRow(mActivity); tv1 = new TextView(mActivity); tv2 = new TextView(mActivity); tv3 = new TextView(mActivity); //tv4 = new TextView(mActivity); tv1.setText(" " + mListAv.get(i).get(0)); tv2.setText(" " + mListAv.get(i).get(1)); tv3.setText(" " + mListAv.get(i).get(2)); //tv4.setText(" " + mListAv.get(i).get(3)); tv1.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Medium); tv2.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Medium); tv3.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Medium); //tv4.setTextAppearance(mActivity,android.R.style.TextAppearance_DeviceDefault_Medium); tv1.setPadding(5, 5, 5, 5); tv2.setPadding(5, 5, 5, 5); tv3.setPadding(5, 5, 5, 5); //tv4.setPadding(5,5,5,5); /*tv2.setBackgroundResource(R.drawable.card_divider); tv3.setBackgroundResource(R.drawable.card_divider); tv4.setBackgroundResource(R.drawable.card_divider);*/ row.addView(tv1); row.addView(tv2); row.addView(tv3); //row.addView(tv4); row.setBackgroundResource(R.drawable.button_selector); row.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL); row.setOnClickListener(this); mTblLayoutAv.addView(row); } LinearLayout ll = new LinearLayout(mActivity); ScrollView scrollView = new ScrollView(mActivity); TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText("Availability details:"); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); ll.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); ll.setOrientation(LinearLayout.VERTICAL); ll.addView(textViewTrnDtls); ll.addView(mTblLayoutAv); scrollView.addView(ll); mFrameLayout.removeAllViews(); mFrameLayout.addView(scrollView); if (mDialog.isShowing()) { mDialog.cancel(); } }
From source file:com.example.drugsformarinemammals.General_Info_Drug.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.general_info_drug); isStoredInLocal = false;/* w w w .j av a2 s .c om*/ fiveLastScreen = false; helper = new Handler_Sqlite(this); helper.open(); Bundle extras1 = this.getIntent().getExtras(); if (extras1 != null) { infoBundle = extras1.getStringArrayList("generalInfoDrug"); fiveLastScreen = extras1.getBoolean("fiveLastScreen"); if (infoBundle == null) isStoredInLocal = true; if (!isStoredInLocal) { initializeGeneralInfoDrug(); initializeCodesInformation(); initializeCodes(); } else { drug_name = extras1.getString("drugName"); codes = helper.getCodes(drug_name); codesInformation = helper.getCodesInformation(drug_name); } //Title TextView drugTitle = (TextView) findViewById(R.id.drugTitle); drugTitle.setText(drug_name); drugTitle.setTypeface(Typeface.SANS_SERIF); //Description LinearLayout borderDescription = new LinearLayout(this); borderDescription.setOrientation(LinearLayout.VERTICAL); borderDescription .setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); borderDescription.setBackgroundResource(R.drawable.layout_border); TextView description = new TextView(this); if (isStoredInLocal) description.setText(helper.getDescription(drug_name)); else description.setText(this.description); description.setTextSize(18); description.setTypeface(Typeface.SANS_SERIF); LinearLayout.LayoutParams paramsDescription = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); paramsDescription.leftMargin = 60; paramsDescription.rightMargin = 60; paramsDescription.topMargin = 20; borderDescription.addView(description, borderDescription.getChildCount(), paramsDescription); LinearLayout layoutDescription = (LinearLayout) findViewById(R.id.layoutDescription); layoutDescription.addView(borderDescription, layoutDescription.getChildCount()); //Animals TextView headerAnimals = (TextView) findViewById(R.id.headerAnimals); headerAnimals.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD); Button cetaceansButton = (Button) findViewById(R.id.cetaceansButton); cetaceansButton.setText("CETACEANS"); cetaceansButton.setTypeface(Typeface.SANS_SERIF); cetaceansButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { showDoseInformation(drug_name, "Cetaceans"); } }); Button pinnipedsButton = (Button) findViewById(R.id.pinnipedsButton); pinnipedsButton.setText("PINNIPEDS"); pinnipedsButton.setTypeface(Typeface.SANS_SERIF); pinnipedsButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { SQLiteDatabase db = helper.open(); ArrayList<String> families = new ArrayList<String>(); if (db != null) families = helper.read_animals_family(drug_name, "Pinnipeds"); if ((families != null && families.size() == 1 && families.get(0).equals("")) || (families != null && families.size() == 0)) showDoseInformation(drug_name, "Pinnipeds"); else showDoseInformationPinnipeds(drug_name, families); } }); Button otherButton = (Button) findViewById(R.id.otherButton); otherButton.setText("OTHER MM"); otherButton.setTypeface(Typeface.SANS_SERIF); otherButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { showDoseInformation(drug_name, "Other MM"); } }); //Codes & therapeutic target & anatomical target TextView headerATCvetCodes = (TextView) findViewById(R.id.headerATCvetCodes); headerATCvetCodes.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD); //Action TextView headerActionAnatomical = (TextView) findViewById(R.id.headerActionAnatomical); headerActionAnatomical.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD); createTextViewAnatomical(); createBorderAnatomicalGroup(); TextView headerActionTherapeutic = (TextView) findViewById(R.id.headerActionTherapeutic); headerActionTherapeutic.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD); createTextViewTherapeutic(); createBorderTherapeuticGroup(); params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); params.leftMargin = 60; params.rightMargin = 60; params.topMargin = 20; Spinner codesSpinner = (Spinner) findViewById(R.id.codesSpinner); SpinnerAdapter adapterCodes = new SpinnerAdapter(this, R.layout.item_spinner, codes); adapterCodes.setDropDownViewResource(R.layout.spinner_dropdown_item); codesSpinner.setAdapter(adapterCodes); codesSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View arg1, int arg2, long arg3) { userEntryCode = parent.getSelectedItem().toString(); int numCodes = codesInformation.size(); layoutAnatomicalGroup.removeView(borderAnatomicalGroup); createBorderAnatomicalGroup(); boolean founded = false; int i = 0; while (!founded && i < numCodes) { if (userEntryCode.equals(codesInformation.get(i).getCode())) { createTextViewAnatomical(); anatomicalGroup.setText(codesInformation.get(i).getAnatomic_group() + "\n"); borderAnatomicalGroup.addView(anatomicalGroup, borderAnatomicalGroup.getChildCount(), params); founded = true; } i++; } layoutAnatomicalGroup = (LinearLayout) findViewById(R.id.layoutActionAnatomical); layoutAnatomicalGroup.addView(borderAnatomicalGroup, layoutAnatomicalGroup.getChildCount()); layoutTherapeuticGroup.removeView(borderTherapeuticGroup); createBorderTherapeuticGroup(); founded = false; i = 0; while (!founded && i < numCodes) { if (userEntryCode.equals(codesInformation.get(i).getCode())) { createTextViewTherapeutic(); therapeuticGroup.setText(codesInformation.get(i).getTherapeutic_group() + "\n"); borderTherapeuticGroup.addView(therapeuticGroup, borderTherapeuticGroup.getChildCount(), params); founded = true; } i++; } layoutTherapeuticGroup = (LinearLayout) findViewById(R.id.layoutActionTherapeutic); layoutTherapeuticGroup.addView(borderTherapeuticGroup, layoutTherapeuticGroup.getChildCount()); } public void onNothingSelected(AdapterView<?> arg0) { } }); layoutAnatomicalGroup = (LinearLayout) findViewById(R.id.layoutActionAnatomical); layoutTherapeuticGroup = (LinearLayout) findViewById(R.id.layoutActionTherapeutic); borderTherapeuticGroup.addView(therapeuticGroup, borderTherapeuticGroup.getChildCount(), params); borderAnatomicalGroup.addView(anatomicalGroup, borderAnatomicalGroup.getChildCount(), params); layoutAnatomicalGroup.addView(borderAnatomicalGroup, layoutAnatomicalGroup.getChildCount()); layoutTherapeuticGroup.addView(borderTherapeuticGroup, layoutTherapeuticGroup.getChildCount()); //Generic Drug TextView headerGenericDrug = (TextView) findViewById(R.id.headerGenericDrug); headerGenericDrug.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD); boolean isAvalaible = false; if (isStoredInLocal) isAvalaible = helper.isAvalaible(drug_name); else isAvalaible = available.equals("Yes"); if (isAvalaible) { ImageView genericDrug = new ImageView(this); genericDrug.setImageResource(R.drawable.tick_verde); LinearLayout layoutGenericDrug = (LinearLayout) findViewById(R.id.layoutGenericDrug); layoutGenericDrug.addView(genericDrug); } else { Typeface font = Typeface.createFromAsset(getAssets(), "Typoster_demo.otf"); TextView genericDrug = new TextView(this); genericDrug.setTypeface(font); genericDrug.setText("Nd"); genericDrug.setTextColor(getResources().getColor(R.color.maroon)); genericDrug.setTextSize(20); DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); int size = metrics.widthPixels; int middle = size / 2; int quarter = size / 4; genericDrug.setTranslationX(middle - quarter); genericDrug.setTranslationY(-3); LinearLayout layoutGenericDrug = (LinearLayout) findViewById(R.id.layoutGenericDrug); layoutGenericDrug.addView(genericDrug); } //Licenses TextView headerLicense = (TextView) findViewById(R.id.headerLicense); headerLicense.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD); TextView fdaLicense = (TextView) findViewById(R.id.license1); Typeface font = Typeface.createFromAsset(getAssets(), "Typoster_demo.otf"); fdaLicense.setTypeface(font); String fda; if (isStoredInLocal) fda = helper.getLicense_FDA(drug_name); else fda = license_FDA; if (fda.equals("Yes")) { fdaLicense.setText("Yes"); fdaLicense.setTextColor(getResources().getColor(R.color.lightGreen)); } else { fdaLicense.setText("Nd"); fdaLicense.setTextColor(getResources().getColor(R.color.maroon)); } TextView emaLicense = (TextView) findViewById(R.id.license3); emaLicense.setTypeface(font); String ema; if (isStoredInLocal) ema = helper.getLicense_EMA(drug_name); else ema = license_EMA; if (ema.equals("Yes")) { emaLicense.setText("Yes"); emaLicense.setTextColor(getResources().getColor(R.color.lightGreen)); } else { emaLicense.setText("Nd"); emaLicense.setTextColor(getResources().getColor(R.color.maroon)); } TextView aempsLicense = (TextView) findViewById(R.id.license2); aempsLicense.setTypeface(font); String aemps; if (isStoredInLocal) aemps = helper.getLicense_AEMPS(drug_name); else aemps = license_AEMPS; if (aemps.equals("Yes")) { aempsLicense.setText("Yes"); aempsLicense.setTextColor(getResources().getColor(R.color.lightGreen)); } else { aempsLicense.setText("Nd"); aempsLicense.setTextColor(getResources().getColor(R.color.maroon)); } ImageButton food_and_drug = (ImageButton) findViewById(R.id.food_and_drug); food_and_drug.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse( "http://www.fda.gov/animalveterinary/products/approvedanimaldrugproducts/default.htm")); startActivity(intent); } }); ImageButton european_medicines_agency = (ImageButton) findViewById(R.id.european_medicines_agency); european_medicines_agency.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse( "http://www.ema.europa.eu/ema/index.jsp?curl=pages/medicines/landing/vet_epar_search.jsp&mid=WC0b01ac058001fa1c")); startActivity(intent); } }); ImageButton logo_aemps = (ImageButton) findViewById(R.id.logo_aemps); logo_aemps.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse( "http://www.aemps.gob.es/medicamentosVeterinarios/Med-Vet-autorizados/home.htm")); startActivity(intent); } }); if (helper.existDrug(drug_name)) { int drug_priority = helper.getDrugPriority(drug_name); ArrayList<String> sorted_drugs = new ArrayList<String>(); sorted_drugs.add(0, drug_name); for (int i = 1; i < drug_priority; i++) { String name = helper.getDrugName(i); sorted_drugs.add(i, name); } for (int i = 0; i < sorted_drugs.size(); i++) helper.setDrugPriority(sorted_drugs.get(i), i + 1); } if (!isStoredInLocal) { //Server code String[] urls = { "http://formmulary.tk/Android/getDoseInformation.php?drug_name=", "http://formmulary.tk/Android/getGeneralNotesInformation.php?drug_name=" }; new GetDoseInformation(this).execute(urls); } helper.close(); } }
From source file:com.adithyaupadhya.uimodule.roundcornerprogressbar.BaseRoundCornerProgressBar.java
private void setupReverse(LinearLayout layoutProgress) { RelativeLayout.LayoutParams progressParams = (RelativeLayout.LayoutParams) layoutProgress.getLayoutParams(); removeLayoutParamsRule(progressParams); if (isReverse) { progressParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); // For support with RTL on API 17 or more if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) progressParams.addRule(RelativeLayout.ALIGN_PARENT_END); } else {/* w ww . j a va 2s . c om*/ progressParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT); // For support with RTL on API 17 or more if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) progressParams.addRule(RelativeLayout.ALIGN_PARENT_START); } layoutProgress.setLayoutParams(progressParams); }
From source file:hu.fnf.devel.atlas.Atlas.java
private void addChilds(View parent, LinearLayout pll) { Uri.Builder builder = new Builder(); builder.scheme("content"); builder.authority(AtlasData.DB_AUTHORITY); builder.appendPath(AtlasData.TABLE_CATEGORIES); builder.appendPath("childs"); builder.appendPath(String.valueOf(parent.getId())); Cursor items = getContentResolver().query(builder.build(), AtlasData.CATEGORIES_COLUMNS, null, null, null); if (items != null && items.moveToFirst()) { LinearLayout ll = null; do {// w ww.ja v a2 s . c o m ll = new LinearLayout(getApplicationContext()); LayoutParams llp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); ll.setLayoutParams(llp); TextView child = new TextView(getApplicationContext()); child.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_Medium_Inverse); ll.setId(items.getInt(AtlasData.CATEGORIES_ID)); child.setId(items.getInt(AtlasData.CATEGORIES_ID)); child.setText(items.getString(AtlasData.CATEGORIES_NAME)); for (int i = 0; i < AtlasData.MAX_CAT_DEPTH - items.getInt(AtlasData.CATEGORIES_DEPTH); i++) { TextView holder = new TextView(getApplicationContext()); holder.setText(" "); ll.addView(holder); } child.setClickable(true); Log.d("Atlas", "build to ll: " + child.getText().toString()); ll.addView(child); ll.setOnClickListener(onCatClick); child.setOnClickListener(onCatClick); View line = new View(getApplicationContext()); line.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, 1)); line.setBackgroundColor(Color.GRAY); pll.addView(line); pll.addView(ll); Log.d("Atlas", "build to pll: " + ll.getId()); addChilds(child, pll); } while (items.moveToNext()); items.close(); } else { // no more kids return; } }
From source file:com.brq.wallet.activity.modern.AccountsFragment.java
private LinearLayout createActiveAccountBalanceSumView(CurrencySum spendableBalance) { LinearLayout outer = new LinearLayout(getActivity()); outer.setOrientation(LinearLayout.VERTICAL); outer.setLayoutParams(_outerLayoutParameters); LinearLayout inner = new LinearLayout(getActivity()); inner.setOrientation(LinearLayout.VERTICAL); inner.setLayoutParams(_innerLayoutParameters); inner.requestLayout();/* www . jav a 2s. co m*/ // Add records RecordRowBuilder builder = new RecordRowBuilder(_mbwManager, getResources(), _layoutInflater); // Add item View item = builder.buildTotalView(outer, spendableBalance); inner.addView(item); // Add separator inner.addView(createSeparator()); outer.addView(inner); return outer; }
From source file:com.geoffreybuttercrumbs.arewethereyet.DrawerFragment.java
private void saved() { ////////S-A-V-E-D/////////// LinearLayout SavedParent = (LinearLayout) V.findViewById(R.id.group_pinned); LayoutInflater inflater = getActivity().getLayoutInflater(); //If there are no pinned alarms if (touchSaveIndex(0) < 1) { View Saved = inflater.inflate(R.layout.saved_item, null); Saved.setOnClickListener(this); ((TextView) Saved.findViewById(R.id.savedLabel)).setText("No Pinned Alarms"); ((TextView) Saved.findViewById(R.id.savedLabel)).setTextColor(0xDD999999); ((CheckBox) Saved.findViewById(R.id.saveCB)).setChecked(true); Saved.findViewById(R.id.saveCB).setEnabled(false); ((CompoundButton) Saved.findViewById(R.id.saveCB)).setOnCheckedChangeListener(this); LinearLayout.LayoutParams sparams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); SavedParent.setLayoutParams(sparams); SavedParent.addView(Saved);// w ww. j a v a2 s . co m } else { for (int i = 1; i <= touchSaveIndex(0); i++) { // View Saved = new View(getApplicationContext()); View Saved = inflater.inflate(R.layout.saved_item, null); Saved.setOnClickListener(this); SharedPreferences prefs = getActivity().getSharedPreferences("AreWeThereYet", Context.MODE_WORLD_WRITEABLE); Location location = new Location("POINT_LOCATION"); location.setLatitude(0); location.setLongitude(0); String address = "No Pinned Alarms"; if (prefs.contains(SAVED_LATITUDE_KEY + i)) { location.setLatitude(prefs.getFloat(SAVED_LATITUDE_KEY + i, 0)); } if (prefs.contains(SAVED_LONGITUDE_KEY + i)) { location.setLongitude(prefs.getFloat(SAVED_LONGITUDE_KEY + i, 0)); } if (prefs.contains(SAVED_ADDRESS_KEY + i)) { address = (prefs.getString(SAVED_ADDRESS_KEY + i, "")); } CharSequence name; if (!address.equals("")) { name = address; ((TextView) Saved.findViewById(R.id.savedLabel)).setTextColor(0xDDFFFFFF); ((CheckBox) Saved.findViewById(R.id.saveCB)).setChecked(true); Saved.findViewById(R.id.saveCB).setTag(i); ((CompoundButton) Saved.findViewById(R.id.saveCB)).setOnCheckedChangeListener(this); } else { name = "Error"; ((TextView) Saved.findViewById(R.id.savedLabel)).setTextColor(0xDD999999); ((CheckBox) Saved.findViewById(R.id.saveCB)).setChecked(true); Saved.findViewById(R.id.saveCB).setEnabled(false); } ((CompoundButton) Saved.findViewById(R.id.saveCB)).setOnCheckedChangeListener(this); ((TextView) Saved.findViewById(R.id.savedLabel)).setText(name); ((TextView) Saved.findViewById(R.id.savedLabel)).setTextSize(14); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); SavedParent.setLayoutParams(params); SavedParent.addView(Saved); } } }