List of usage examples for android.widget LinearLayout setGravity
@android.view.RemotableViewMethod public void setGravity(int gravity)
From source file:com.TakeTaxi.jy.OnrouteScreen.java
public void pingpicked(JSONObject json) { try {//from www .j a v a2 s . co m int driverpicked = json.getInt("picked"); int drivercancelled = json.getInt("dcancel"); int starttime = json.getInt("datetime"); // /////////////////////////////// DRIVER CANCEL //////// if (drivercancelled == 1) { // //// DRIVER CANCEL LATE ///// if (starttime + 300 <= Query.getServerTime()) { handlerboolean = false; handler.removeCallbacks(r); AlertDialog dcancelbuilder = new AlertDialog.Builder(OnrouteScreen.this).create(); dcancelbuilder .setMessage("Job has been cancelled.\nWould you like to report a late cancellation?."); // //// DRIVER CANCEL LATE - NO REPORT LATE///// button_cancelJob_noquery(dcancelbuilder); // //// DRIVER CANCEL LATE - REPORT LATE ///// button_drivercancel_reportlate(dcancelbuilder); dcancelbuilder.show(); } else { // /////////////////////////////// DRIVER CANCEL NO ALERTS - // WITHIN TIME LIMIT/////////////// handlerboolean = false; handler.removeCallbacks(r); alertdialog_drivercancelintime(); } } if (driverpicked == 1) { // /////////////////////////////// CONFIRM PICK UP // /////////////////////////////////////////// handlerboolean = false; handler.removeCallbacks(r); AlertDialog.Builder alert = new AlertDialog.Builder(OnrouteScreen.this); final Drawable thumbsup = getResources().getDrawable(R.drawable.thumbsup); final Drawable thumbsupwhite = getResources().getDrawable(R.drawable.thumbsupwhite); final Drawable thumbsdown = getResources().getDrawable(R.drawable.thumbsdown); final Drawable thumbsdownwhite = getResources().getDrawable(R.drawable.thumbsdownwhite); LinearLayout layout = new LinearLayout(OnrouteScreen.this); layout.setOrientation(1); layout.setGravity(17); TextView tx1 = new TextView(OnrouteScreen.this); tx1.setText("Driver says you have been picked up"); tx1.setGravity(17); tx1.setTextSize(20); tx1.setTextColor(Color.WHITE); tx1.setPadding(10, 10, 10, 10); TextView tx2 = new TextView(OnrouteScreen.this); tx2.setText("Please rate your driver"); tx2.setGravity(17); tx2.setTextSize(16); LinearLayout imglayout = new LinearLayout(OnrouteScreen.this); imglayout.setOrientation(0); imglayout.setGravity(17); final ImageView ivup = new ImageView(OnrouteScreen.this); ivup.setImageDrawable(thumbsupwhite); ivup.setClickable(true); ivup.setPadding(0, 5, 30, 5); final ImageView ivdown = new ImageView(OnrouteScreen.this); ivdown.setImageDrawable(thumbsdownwhite); ivdown.setClickable(true); ivup.setPadding(30, 5, 0, 5); imglayout.addView(ivup); imglayout.addView(ivdown); layout.addView(tx1); layout.addView(tx2); layout.addView(imglayout); // /////////////////////////////// CONFIRM PICK UP - RATINGS // /////////////////////////////////////////// ivup.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (thumbsupboolean == false) { thumbsupboolean = true; thumbsdownboolean = false; ivup.setImageDrawable(thumbsup); ivdown.setImageDrawable(thumbsdownwhite); rating = 1; } else { thumbsupboolean = false; ivup.setImageDrawable(thumbsupwhite); rating = 0; } } }); ivdown.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (thumbsdownboolean == false) { thumbsdownboolean = true; thumbsupboolean = false; ivdown.setImageDrawable(thumbsdown); ivup.setImageDrawable(thumbsupwhite); AlertDialog alert = new AlertDialog.Builder(OnrouteScreen.this).create(); alert.setMessage("Please pick one"); alert.setButton("No show", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { rating = -1; } }); alert.setButton2("Driver late", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { rating = -2; } }); alert.setButton3("Poor service", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { rating = -3; } }); alert.show(); } else { thumbsupboolean = false; ivdown.setImageDrawable(thumbsdownwhite); rating = 0; } } }); button_completed_finish(alert); alert.setView(layout); alert.create(); alert.show(); } else { } } catch (JSONException e) { } }
From source file:com.rainmakerlabs.bleepsample.BleepService.java
public void imgShow(Bitmap bitmap, String strImgMsg) { MainActivity.adlib.put(strImgMsg, bitmap); Log.d("Portal", "Added an image. Size is now " + MainActivity.adlib.size()); Log.i("Portal", "Image added for key " + strImgMsg); if (MainActivity.myGallery == null) return;/*from w ww. ja v a 2 s . com*/ if (MainActivity.gal_size < MainActivity.adlib.size()) { //new image has been added and the layout is initialized LinearLayout superLL = (LinearLayout) MainActivity.myGallery.getParent().getParent(); if (MainActivity.gal_size < 1) { ImageView imgSplash = (ImageView) superLL.findViewById(R.id.imgSplash); imgSplash.setVisibility(View.INVISIBLE); } LinearLayout layout = new LinearLayout(getApplicationContext()); layout.setOrientation(LinearLayout.VERTICAL); layout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); layout.setGravity(Gravity.CENTER); ImageView imageview = new ImageView(getApplicationContext()); imageview.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, 1000)); imageview.setScaleType(ImageView.ScaleType.CENTER_CROP); imageview.setImageBitmap(bitmap); //Add a button to go with it Button btnBuy = new Button(getApplicationContext()); LinearLayout.LayoutParams btnParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); btnParams.setMargins(-10, -10, -10, -10); btnBuy.setLayoutParams(btnParams); btnBuy.setText("Buy Now (" + strImgMsg + ")"); btnBuy.setBackgroundColor(MainActivity.getDominantColor(bitmap)); btnBuy.setTextColor(Color.WHITE); btnBuy.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { Intent newActivity = new Intent(getApplicationContext(), WebActivity.class); newActivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); newActivity.putExtra("URL", "https://portal-battlehack.herokuapp.com/"); startActivity(newActivity); } }); layout.addView(imageview); layout.addView(btnBuy); MainActivity.myGallery.addView(layout); MainActivity.gal_size++; } }
From source file:com.research.widget.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { LinearLayout item = new LinearLayout(getContext()); item.setOrientation(LinearLayout.HORIZONTAL); item.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL); TextView tab = new TextView(getContext()); tab.setText(title);// www . ja v a 2s . c o m tab.setGravity(Gravity.CENTER); tab.setSingleLine(); TextView msgTipText = new TextView(getContext()); msgTipText.setGravity(Gravity.CENTER); msgTipText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 10); msgTipText.setSingleLine(); msgTipText.setTextColor(Color.parseColor("#ffffff")); if (position != 0) { msgTipText.setBackgroundDrawable(getContext().getResources().getDrawable(R.drawable.main_find_icon)); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( FeatureFunction.dip2px(BMapApiApp.getInstance(), 10), FeatureFunction.dip2px(BMapApiApp.getInstance(), 10)); msgTipText.setLayoutParams(params); } else { msgTipText.setBackgroundDrawable(getContext().getResources().getDrawable(R.drawable.message_count_bg)); } msgTipText.setVisibility(View.GONE); item.addView(tab); item.addView(msgTipText); addTab(position, item); }
From source file:com.common.widget.pageindicator.C_TabPageIndicator.java
@SuppressLint("NewApi") // private void addTab(int index, CharSequence text, int iconResId) { // final TabView tabView = new TabView(getContext()); // tabView.mIndex = index; // tabView.setFocusable(true); // tabView.setOnClickListener(mTabClickListener); // tabView.setText(text); // if (iconResId != 0) { // // tabView.setCompoundDrawablePadding( // // (int) getResources().getDimension(R.dimen.margin1)); // tabView.setCompoundDrawablesWithIntrinsicBounds(0, iconResId, 0, 0); // // setTabIcon(tabView, iconResId); // }//from w ww. j a va2 s. c o m // if (deviceWeight) { // mTabLayout.addView(tabView, new LinearLayout.LayoutParams(0, // MATCH_PARENT, 1)); // } else { // LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( // WRAP_CONTENT, MATCH_PARENT); // lp.leftMargin = 10; // lp.rightMargin = 10; // mTabLayout.addView(tabView, lp); // } // } private void addTab(int index, CharSequence text, int iconResId) { if (deviceWeight) { // tab ? Layout LinearLayout layout = new LinearLayout(getContext()); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(WRAP_CONTENT, MATCH_PARENT, 1); //???GG layout.setBackgroundColor(C_ResUtil.getSrcColor(R.color.full_transparent)); layout.setGravity(Gravity.CENTER); // TextView final TabView tabView = new TabView(getContext()); tabView.mIndex = index; // ?layoutLayout??? tabView.setFocusable(false); tabView.setClickable(false); tabView.setOnClickListener(mTabClickListener); tabView.setText(text); if (iconResId != 0) { // tabView.setCompoundDrawablesWithIntrinsicBounds(0, iconResId, // 0, 0); // tabView.setPaddingRelative(10, 10, 10, 10); // tabView.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, // iconResId, 0); tabView.setBackgroundResource(iconResId); } tabView.setPadding(C_ResUtil.getDimens(R.dimen._10dp), 0, C_ResUtil.getDimens(R.dimen._10dp), 0); LinearLayout.LayoutParams tvlp = new LinearLayout.LayoutParams(WRAP_CONTENT, C_ResUtil.getDimens(R.dimen._22dp)); tvlp.rightMargin = C_ResUtil.getDimens(R.dimen._2dp); tvlp.leftMargin = C_ResUtil.getDimens(R.dimen._2dp); layout.addView(tabView, tvlp); layout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tabView.performClick(); } }); // TextView mTabLayout.addView(layout, lp); } else { final TabView tabView = new TabView(getContext()); tabView.mIndex = index; tabView.setFocusable(true); tabView.setOnClickListener(mTabClickListener); tabView.setText(text); if (iconResId != 0) { // tabView.setCompoundDrawablePadding( // (int) getResources().getDimension(R.dimen.margin1)); // tabView.setCompoundDrawablesWithIntrinsicBounds(0, iconResId, // 0, 0); tabView.setPaddingRelative(10, 10, 10, 10); tabView.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, iconResId, 0); // setTabIcon(tabView, iconResId); } tabView.setPadding(C_ResUtil.getDimens(R.dimen._10dp), 0, C_ResUtil.getDimens(R.dimen._10dp), 0); // if (deviceWeight) { // mTabLayout.addView(tabView, new LinearLayout.LayoutParams(0, // MATCH_PARENT, 1)); // } else { LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(WRAP_CONTENT, C_ResUtil.getDimens(R.dimen._22dp)); lp.leftMargin = C_ResUtil.getDimens(R.dimen._2dp); lp.rightMargin = C_ResUtil.getDimens(R.dimen._2dp); // mTabLayout.addView(tabView, lp); // } } }
From source file:it.iziozi.iziozi.gui.IOBoardFragment.java
private View buildView(boolean editMode) { this.homeRows.clear(); final List<IOSpeakableImageButton> mButtons = new ArrayList<IOSpeakableImageButton>(); List<IOSpeakableImageButton> configButtons = this.mBoard.getButtons(); ViewGroup mainView = (ViewGroup) getActivity().getLayoutInflater().inflate(R.layout.table_main_layout, null);// w ww. jav a 2 s .co m LinearLayout tableContainer = new LinearLayout(getActivity()); LinearLayout.LayoutParams mainParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); tableContainer.setLayoutParams(mainParams); tableContainer.setOrientation(LinearLayout.VERTICAL); for (int i = 0; i < this.mBoard.getRows(); i++) { LinearLayout rowLayout = new LinearLayout(getActivity()); LinearLayout.LayoutParams rowParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, 0, 1.f); rowLayout.setLayoutParams(rowParams); rowLayout.setOrientation(LinearLayout.HORIZONTAL); Random color = new Random(); rowLayout.setBackgroundColor(Color.WHITE); tableContainer.addView(rowLayout); this.homeRows.add(rowLayout); } for (int j = 0; j < this.homeRows.size(); j++) { LinearLayout homeRow = this.homeRows.get(j); for (int i = 0; i < this.mBoard.getCols(); i++) { LinearLayout btnContainer = new LinearLayout(getActivity()); LinearLayout.LayoutParams btnContainerParams = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1.f); btnContainer.setLayoutParams(btnContainerParams); btnContainer.setOrientation(LinearLayout.VERTICAL); btnContainer.setGravity(Gravity.CENTER); homeRow.addView(btnContainer); final IOSpeakableImageButton imgButton = (configButtons.size() > 0 && configButtons.size() > mButtons.size()) ? configButtons.get(mButtons.size()) : new IOSpeakableImageButton(getActivity()); imgButton.setmContext(getActivity()); imgButton.setShowBorder(IOConfiguration.getShowBorders()); if (IOGlobalConfiguration.isEditing) imgButton.setImageDrawable(getResources().getDrawable(R.drawable.logo_org)); else imgButton.setImageDrawable(null); imgButton.setScaleType(ImageView.ScaleType.CENTER_INSIDE); imgButton.setBackgroundColor(Color.TRANSPARENT); if (imgButton.getmImageFile() != null && imgButton.getmImageFile().length() > 0) { if (!new File(imgButton.getmImageFile()).exists()) { if (mAlertDialog == null || !mAlertDialog.isShowing()) { mAlertDialog = new AlertDialog.Builder(getActivity()).setCancelable(true) .setTitle(getString(R.string.image_missing)) .setMessage(getString(R.string.image_missing_text)) .setNegativeButton(getString(R.string.continue_string), null).create(); mAlertDialog.show(); } //download image if (isExternalStorageReadable()) { File baseFolder = new File(Environment.getExternalStorageDirectory() + "/" + IOApplication.APPLICATION_FOLDER + "/pictograms"); Character pictoChar = imgButton.getmImageFile() .charAt(imgButton.getmImageFile().lastIndexOf("/") + 1); File pictoFolder = new File(baseFolder + "/" + pictoChar + "/"); if (isExternalStorageWritable()) { pictoFolder.mkdirs(); //download it AsyncHttpClient client = new AsyncHttpClient(); client.get(imgButton.getmUrl(), new FileAsyncHttpResponseHandler(new File(imgButton.getmImageFile())) { @Override public void onFailure(int statusCode, Header[] headers, Throwable throwable, File file) { Toast.makeText(getActivity(), getString(R.string.download_error) + file.toString(), Toast.LENGTH_LONG).show(); } @Override public void onSuccess(int statusCode, Header[] headers, File downloadedFile) { if (new File(imgButton.getmImageFile()).exists()) { imgButton.setImageBitmap( BitmapFactory.decodeFile(imgButton.getmImageFile())); } else { Toast.makeText(getActivity(), getString(R.string.image_save_error), Toast.LENGTH_SHORT).show(); } } }); } else { Toast.makeText(getActivity(), getString(R.string.image_save_error), Toast.LENGTH_SHORT).show(); } } else { Toast.makeText(getActivity(), getString(R.string.image_save_error), Toast.LENGTH_SHORT) .show(); } } else imgButton.setImageBitmap(BitmapFactory.decodeFile(imgButton.getmImageFile())); } ViewGroup parent = (ViewGroup) imgButton.getParent(); if (parent != null) parent.removeAllViews(); btnContainer.addView(imgButton); mButtons.add(imgButton); imgButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int index = mButtons.indexOf(v); if (mListener != null) mListener.tapOnSpeakableButton(mButtons.get(index), mBoardLevel); } }); } } this.mBoard.setButtons(mButtons.size() > configButtons.size() ? mButtons : configButtons); return tableContainer; }
From source file:com.example.damerap_ver1.IntroVideoActivity.java
/** * Create the view in which the video will be rendered. *///ww w. ja v a2 s . c o m private void setupView() { LinearLayout lLinLayout = new LinearLayout(this); lLinLayout.setId(1); lLinLayout.setOrientation(LinearLayout.VERTICAL); lLinLayout.setGravity(Gravity.CENTER); lLinLayout.setBackgroundColor(Color.BLACK); LayoutParams lLinLayoutParms = new LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT); lLinLayout.setLayoutParams(lLinLayoutParms); this.setContentView(lLinLayout); RelativeLayout lRelLayout = new RelativeLayout(this); lRelLayout.setId(2); lRelLayout.setGravity(Gravity.CENTER); lRelLayout.setBackgroundColor(Color.BLACK); android.widget.RelativeLayout.LayoutParams lRelLayoutParms = new android.widget.RelativeLayout.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT); lRelLayout.setLayoutParams(lRelLayoutParms); lLinLayout.addView(lRelLayout); mVideoView = new VideoView(this); mVideoView.setId(3); android.widget.RelativeLayout.LayoutParams lVidViewLayoutParams = new android.widget.RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); lVidViewLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); mVideoView.setLayoutParams(lVidViewLayoutParams); lRelLayout.addView(mVideoView); mProgressBar = new ProgressBar(this); mProgressBar.setId(4); android.widget.RelativeLayout.LayoutParams lProgressBarLayoutParms = new android.widget.RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); lProgressBarLayoutParms.addRule(RelativeLayout.CENTER_IN_PARENT); mProgressBar.setLayoutParams(lProgressBarLayoutParms); lRelLayout.addView(mProgressBar); mProgressMessage = new TextView(this); mProgressMessage.setId(5); android.widget.RelativeLayout.LayoutParams lProgressMsgLayoutParms = new android.widget.RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); lProgressMsgLayoutParms.addRule(RelativeLayout.CENTER_HORIZONTAL); lProgressMsgLayoutParms.addRule(RelativeLayout.BELOW, 4); mProgressMessage.setLayoutParams(lProgressMsgLayoutParms); mProgressMessage.setTextColor(Color.LTGRAY); mProgressMessage.setTextSize(TypedValue.COMPLEX_UNIT_PT, 8); mProgressMessage.setText("..."); lRelLayout.addView(mProgressMessage); }
From source file:com.taobao.weex.extend.module.actionsheet.WXActionSheet.java
private void ensureTitle() { if (!TextUtils.isEmpty(titleText) || !TextUtils.isEmpty(messageText)) { LinearLayout titleContainer = new LinearLayout(getActivity()); titleContainer.setOrientation(LinearLayout.VERTICAL); titleContainer.setGravity(Gravity.CENTER); titleContainer.setBackgroundColor(Color.WHITE); titleContainer/*from w w w .jav a2 s . c o m*/ .setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dp2px(56))); if (!TextUtils.isEmpty(titleText)) { TextView title = new TextView(getActivity()); title.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); title.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); title.setText(titleText); title.setGravity(Gravity.CENTER_HORIZONTAL); title.setTextColor(COLOR_TITLE); title.getPaint().setFakeBoldText(true); titleContainer.addView(title); } if (!TextUtils.isEmpty(messageText)) { TextView message = new TextView(getActivity()); message.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); message.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12); message.setGravity(Gravity.CENTER_HORIZONTAL); message.setText(messageText); message.setTextColor(COLOR_TITLE); titleContainer.addView(message); } titleContainer.setClickable(true); titleContainer.setFocusableInTouchMode(true); sheetContainer.addView(titleContainer); sheetContainer.addView(createLine()); } }
From source file:com.astuetz.PagerSlidingTabStripPlus.java
private void addTab(final int position, View tab) { tab.setFocusable(true);// ww w. j av a 2 s. c om tab.setPadding(tabPaddingLeft, tabPaddingTop, tabPaddingRight, tabPaddingBottom); LinearLayout tabLayout = new LinearLayout(getContext()); tabLayout.setOrientation(LinearLayout.VERTICAL); tabLayout.setGravity(Gravity.CENTER); tabLayout.addView(tab, 0, defaultTabLayoutParams); tabLayout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pager.setCurrentItem(position); } }); tabsContainer.addView(tabLayout, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams); }
From source file:com.witmoon.xmb.ui.widget.PagerSlidingTabStrip.java
private void addTextIconTab(final int position, String title, int resId) { if (resId == TitleIconTabProvider.NONE_ICON) { addTextTab(position, title);/*w w w. j av a2s . c o m*/ return; } TextView tab = new TextView(getContext()); tab.setText(title); tab.setGravity(Gravity.CENTER); tab.setSingleLine(); ImageView icon = new ImageView(getContext()); if (position == 1) { icon.setImageResource(icoColor1); } else { icon.setImageResource(selectedIcoColor); } LinearLayout linearLayout = new LinearLayout(getContext()); linearLayout.setOrientation(LinearLayout.HORIZONTAL); linearLayout.setGravity(Gravity.CENTER); linearLayout.addView(icon, defaultTabLayoutParams); linearLayout.addView(tab, defaultTabLayoutParams); addTab(position, linearLayout); }
From source file:at.alladin.rmbt.android.map.overlay.RMBTBalloonOverlayView.java
public void setBalloonData(final RMBTBalloonOverlayItem item, final ViewGroup parent) { // map our custom item data to fields // title.setText(item.getTitle()); resultItems = item.getResultItems(); resultListView.removeAllViews();//from w w w . j a v a2s .co m final float scale = getResources().getDisplayMetrics().density; final int leftRightItem = Helperfunctions.dpToPx(5, scale); final int topBottomItem = Helperfunctions.dpToPx(3, scale); final int leftRightDiv = Helperfunctions.dpToPx(0, scale); final int topBottomDiv = Helperfunctions.dpToPx(0, scale); final int heightDiv = Helperfunctions.dpToPx(1, scale); final int topBottomImg = Helperfunctions.dpToPx(1, scale); if (resultItems != null && resultItems.length() > 0) { for (int i = 0; i < 1; i++) // JSONObject resultListItem; try { final JSONObject result = resultItems.getJSONObject(i); final LayoutInflater resultInflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); final View resultView = resultInflater.inflate(R.layout.balloon_overlay_listitem, parent); final LinearLayout measurementLayout = (LinearLayout) resultView .findViewById(R.id.resultMeasurementList); measurementLayout.setVisibility(View.GONE); final LinearLayout netLayout = (LinearLayout) resultView.findViewById(R.id.resultNetList); netLayout.setVisibility(View.GONE); final TextView measurementHeader = (TextView) resultView.findViewById(R.id.resultMeasurement); measurementHeader.setVisibility(View.GONE); final TextView netHeader = (TextView) resultView.findViewById(R.id.resultNet); netHeader.setVisibility(View.GONE); final TextView dateHeader = (TextView) resultView.findViewById(R.id.resultDate); dateHeader.setVisibility(View.GONE); dateHeader.setText(result.optString("time_string")); final JSONArray measurementArray = result.getJSONArray("measurement"); final JSONArray netArray = result.getJSONArray("net"); for (int j = 0; j < measurementArray.length(); j++) { final JSONObject singleItem = measurementArray.getJSONObject(j); final LinearLayout measurememtItemLayout = new LinearLayout(context); // (LinearLayout)measurememtItemView.findViewById(R.id.measurement_item); measurememtItemLayout.setLayoutParams( new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT)); measurememtItemLayout.setGravity(Gravity.CENTER_VERTICAL); measurememtItemLayout.setPadding(leftRightItem, topBottomItem, leftRightItem, topBottomItem); final TextView itemTitle = new TextView(context, null, R.style.balloonResultItemTitle); itemTitle.setLayoutParams( new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 0.4f)); itemTitle.setTextAppearance(context, R.style.balloonResultItemTitle); itemTitle.setWidth(0); itemTitle.setGravity(Gravity.LEFT); itemTitle.setText(singleItem.getString("title")); measurememtItemLayout.addView(itemTitle); final ImageView itemClassification = new ImageView(context); itemClassification.setLayoutParams( new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT, 0.1f)); itemClassification.setPadding(0, topBottomImg, 0, topBottomImg); // itemClassification.set setGravity(Gravity.LEFT); itemClassification.setImageDrawable(getResources().getDrawable( Helperfunctions.getClassificationImage(singleItem.getInt("classification")))); measurememtItemLayout.addView(itemClassification); final TextView itemValue = new TextView(context, null, R.style.balloonResultItemValue); itemValue.setLayoutParams( new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 0.5f)); itemValue.setTextAppearance(context, R.style.balloonResultItemValue); itemValue.setWidth(0); itemValue.setGravity(Gravity.LEFT); itemValue.setText(singleItem.getString("value")); measurememtItemLayout.addView(itemValue); measurementLayout.addView(measurememtItemLayout); final View divider = new View(context); divider.setLayoutParams(new LinearLayout.LayoutParams( android.view.ViewGroup.LayoutParams.MATCH_PARENT, heightDiv, 1)); divider.setPadding(leftRightDiv, topBottomDiv, leftRightDiv, topBottomDiv); divider.setBackgroundResource(R.drawable.bg_trans_light_10); measurementLayout.addView(divider); measurementLayout.invalidate(); } for (int j = 0; j < netArray.length(); j++) { final JSONObject singleItem = netArray.getJSONObject(j); final LinearLayout netItemLayout = new LinearLayout(context); // (LinearLayout)measurememtItemView.findViewById(R.id.measurement_item); netItemLayout.setLayoutParams( new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT)); netItemLayout.setPadding(leftRightItem, topBottomItem, leftRightItem, topBottomItem); netItemLayout.setGravity(Gravity.CENTER_VERTICAL); final TextView itemTitle = new TextView(context, null, R.style.balloonResultItemTitle); itemTitle.setLayoutParams( new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 0.4f)); itemTitle.setTextAppearance(context, R.style.balloonResultItemTitle); itemTitle.setWidth(0); itemTitle.setGravity(Gravity.LEFT); itemTitle.setText(singleItem.getString("title")); netItemLayout.addView(itemTitle); final ImageView itemClassification = new ImageView(context); itemClassification.setLayoutParams( new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT, 0.1f)); itemClassification.setPadding(0, topBottomImg, 0, topBottomImg); itemClassification.setImageDrawable( context.getResources().getDrawable(R.drawable.traffic_lights_none)); netItemLayout.addView(itemClassification); final TextView itemValue = new TextView(context, null, R.style.balloonResultItemValue); itemValue.setLayoutParams( new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 0.5f)); itemValue.setTextAppearance(context, R.style.balloonResultItemValue); itemValue.setWidth(0); itemValue.setGravity(Gravity.LEFT); itemValue.setText(singleItem.optString("value", null)); netItemLayout.addView(itemValue); netLayout.addView(netItemLayout); final View divider = new View(context); divider.setLayoutParams(new LinearLayout.LayoutParams( android.view.ViewGroup.LayoutParams.MATCH_PARENT, heightDiv, 1)); divider.setPadding(leftRightDiv, topBottomDiv, leftRightDiv, topBottomDiv); divider.setBackgroundResource(R.drawable.bg_trans_light_10); netLayout.addView(divider); netLayout.invalidate(); } measurementHeader.setVisibility(View.VISIBLE); netHeader.setVisibility(View.VISIBLE); measurementLayout.setVisibility(View.VISIBLE); netLayout.setVisibility(View.VISIBLE); dateHeader.setVisibility(View.VISIBLE); resultListView.addView(resultView); Log.d(DEBUG_TAG, "View Added"); // codeText.setText(resultListItem.getString("sync_code")); } catch (final JSONException e) { e.printStackTrace(); } progessBar.setVisibility(View.GONE); emptyView.setVisibility(View.GONE); resultListView.setVisibility(View.VISIBLE); resultListView.invalidate(); } else { Log.i(DEBUG_TAG, "LEERE LISTE"); progessBar.setVisibility(View.GONE); emptyView.setVisibility(View.VISIBLE); emptyView.setText(context.getString(R.string.error_no_data)); emptyView.invalidate(); } }