Example usage for android.widget TextView setBackgroundColor

List of usage examples for android.widget TextView setBackgroundColor

Introduction

In this page you can find the example usage for android.widget TextView setBackgroundColor.

Prototype

@RemotableViewMethod
public void setBackgroundColor(@ColorInt int color) 

Source Link

Document

Sets the background color for this view.

Usage

From source file:com.google.android.leanbackjank.presenter.GridItemPresenter.java

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
    TextView view = new TextView(parent.getContext());

    Resources res = parent.getResources();
    int width = res.getDimensionPixelSize(R.dimen.grid_item_width);
    int height = res.getDimensionPixelSize(R.dimen.grid_item_height);

    view.setLayoutParams(new ViewGroup.LayoutParams(width, height));
    view.setFocusable(true);//  w w  w.j a  va2s.c  o  m
    view.setFocusableInTouchMode(true);
    view.setBackgroundColor(ResourcesCompat.getColor(parent.getResources(), R.color.jank_yellow, null));
    view.setTextColor(Color.WHITE);
    view.setGravity(Gravity.CENTER);
    return new ViewHolder(view);
}

From source file:com.aengbee.android.leanback.presenter.GridItemPresenter.java

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
    TextView view = new TextView(parent.getContext());

    Resources res = parent.getResources();
    int width = res.getDimensionPixelSize(R.dimen.grid_item_width);
    int height = res.getDimensionPixelSize(R.dimen.grid_item_height);

    view.setLayoutParams(new ViewGroup.LayoutParams(width, height));
    view.setFocusable(true);//from   w  w  w.j  a v a 2s . c  o  m
    view.setFocusableInTouchMode(true);
    view.setBackgroundColor(ContextCompat.getColor(parent.getContext(), R.color.default_background));
    view.setTextColor(Color.WHITE);
    view.setGravity(Gravity.CENTER);
    return new ViewHolder(view);
}

From source file:de.enlightened.peris.ThemeEditor.java

private void updatePreview() {
    final SharedPreferences appPreferences = getSharedPreferences("prefs", 0);

    final boolean useShading = appPreferences.getBoolean("use_shading", false);
    final boolean useOpenSans = appPreferences.getBoolean("use_opensans", false);
    final int fontSize = appPreferences.getInt("font_size", 16);
    final boolean currentAvatarSetting = appPreferences.getBoolean("show_images", true);

    final TextView themeEditorPreviewAppbar = (TextView) findViewById(R.id.theme_editor_preview_appbar);
    themeEditorPreviewAppbar
            .setBackgroundColor(Color.parseColor(this.application.getSession().getServer().serverColor));

    if (ThemeSetter.getForegroundDark(this.application.getSession().getServer().serverColor)) {
        themeEditorPreviewAppbar.setTextColor(Color.BLACK);
    } else {/*from   ww w. j a  va  2 s .  c  o  m*/
        themeEditorPreviewAppbar.setTextColor(Color.WHITE);
    }

    final FrameLayout themeEditorPreview = (FrameLayout) findViewById(R.id.theme_editor_preview);
    final ImageView themeEditorPreviewWallpaper = (ImageView) findViewById(R.id.theme_editor_preview_wallpaper);

    final String forumWallpaper = this.application.getSession().getServer().serverWallpaper;
    final String forumBackground = this.application.getSession().getServer().serverBackground;

    if (forumWallpaper != null && forumWallpaper.contains("http")) {
        final String imageUrl = forumWallpaper;
        themeEditorPreviewWallpaper.setVisibility(View.VISIBLE);
        ImageLoader.getInstance().displayImage(imageUrl, themeEditorPreviewWallpaper);
    } else {
        themeEditorPreviewWallpaper.setVisibility(View.GONE);
    }

    if (forumBackground != null && forumBackground.contains("#") && forumBackground.length() == 7) {
        themeEditorPreview.setBackgroundColor(Color.parseColor(forumBackground));
    } else {
        themeEditorPreview.setBackgroundColor(Color.parseColor(getString(R.string.default_background)));
    }

    final boolean useDivider = true;
    /*
    if (!(this.application.getSession().getServer().serverBackground.contentEquals(this.application.getSession().getServer().serverBoxColor)
        && this.application.getSession().getServer().serverBoxBorder.contentEquals("0"))) {
      useDivider = false;
    }
    */

    final LinearLayout previewHolder = (LinearLayout) findViewById(R.id.theme_editor_preview_holder);
    previewHolder.removeAllViews();

    final Category sampleCategory = Category.builder().name("Sample Category").build();

    final Topic sampleTopic = Topic.builder().title("Thread Title").type(Topic.Type.Sticky).replyCount(2)
            .viewCount(7).authorName("Author Name").hasNewPosts(true)
            .authorIcon("http://localhost/author_icon.jpg").build();

    final Post po = new Post();
    po.author = "nezkeeeze";
    po.body = "Hey guys I'm new.  How do I get colored text?  Can I be an admin?  How do I start a new topic?<br /><br />"
            + this.application.getSession().getServer().serverTagline;
    po.avatar = "http://localhost/nezkeys.png";

    final LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    final View vC = vi.inflate(R.layout.category, null);
    final View vT = vi.inflate(R.layout.thread, null);
    final View vP = vi.inflate(R.layout.post, null);

    ElementRenderer.renderCategory(vC, this.application, this, useOpenSans, useShading, sampleCategory,
            currentAvatarSetting);
    ElementRenderer.renderCategory(vT, this.application, this, useOpenSans, useShading, sampleTopic,
            currentAvatarSetting);
    ElementRenderer.renderPost(vP, this.application, 1, this, 0, useOpenSans, useShading, po, fontSize,
            currentAvatarSetting);

    previewHolder.addView(vC);

    if (useDivider) {
        final View d1 = vi.inflate(R.layout.preview_seperator, null);
        previewHolder.addView(d1);
    }

    previewHolder.addView(vT);

    if (useDivider) {
        final View d2 = vi.inflate(R.layout.preview_seperator, null);
        previewHolder.addView(d2);
    }

    previewHolder.addView(vP);

    if (useDivider) {
        final View d3 = vi.inflate(R.layout.preview_seperator, null);
        previewHolder.addView(d3);
    }
}

From source file:augsburg.se.alltagsguide.event.EventActivity.java

@Override
protected void setMorePageDetails(EventPage page) {
    int color = mPrefUtilities.getCurrentColor();
    if (mPage.getEvent().isAllDay()) {
        fromDateTextView.setText(allDayDateFormat.format(mPage.getEvent().getStartTime()));
        timeToLayout.setVisibility(View.GONE);
    } else {/* w  w  w  .  j  a  v  a2  s .co  m*/
        fromDateTextView.setText(dateFormatFrom.format(mPage.getEvent().getStartTime()));
        toDateTextView.setText(dateFormatFrom.format(mPage.getEvent().getEndTime()));
    }

    if (mPage.getAuthor() != null) {
        String authorText = mPage.getAuthor().toText();
        if (!Objects.isNullOrEmpty(authorText)) {
            authorTextView.setText(authorText);
        } else {
            authorLayout.setVisibility(View.GONE);
        }
    } else {
        authorLayout.setVisibility(View.GONE);
    }

    if (!mPage.getCategories().isEmpty()) {
        for (EventCategory category : mPage.getCategories()) {
            @SuppressLint("InflateParams")
            TextView view = (TextView) LayoutInflater.from(this).inflate(R.layout.category_item,
                    categoriesLayout, false);
            view.setText(category.getName());
            view.setTextColor(color);
            view.setBackgroundColor(ContextCompat.getColor(this, android.R.color.white));
            categoriesLayout.addView(view);
        }
    } else {
        categoriesBaseLayout.setVisibility(View.GONE);
    }

    if (!mPage.getTags().isEmpty()) {
        for (EventTag tag : mPage.getTags()) {
            @SuppressLint("InflateParams")
            TextView view = (TextView) LayoutInflater.from(this).inflate(R.layout.tag_item, tagsLayout, false);
            view.setText(tag.getName());
            view.setTextColor(ContextCompat.getColor(this, android.R.color.white));
            view.setBackgroundColor(color);
            tagsLayout.addView(view);
        }
    } else {
        tagsLayout.setVisibility(View.GONE);
    }

    if (mPage.getLocation() != null) {
        String location = "";
        String name = mPage.getLocation().getName();
        String address = mPage.getLocation().getAddress();
        if (name != null) {
            location += name + " - ";
        }
        if (address != null) {
            location += address;
        }
        locationTextView.setText(location);
    }
}

From source file:org.cvasilak.jboss.mobile.admin.fragments.ProfileViewFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    Log.d(TAG, "@onCreate()");

    application = (JBossAdminApplication) getActivity().getApplication();

    if (getArguments() != null) {
        this.path = getArguments().getStringArrayList("path");
    }//w w w .j ava2 s  . co  m

    MergeAdapter adapter = new MergeAdapter();

    TextView sectionHeader;

    // Section: Attributes
    sectionHeader = new TextView(getActivity());
    sectionHeader.setBackgroundColor(Color.DKGRAY);
    sectionHeader.setPadding(15, 10, 0, 10);
    sectionHeader.setText(R.string.attributes);
    adapter.addView(sectionHeader);

    attributes = new ArrayList<Attribute>();
    adapter.addAdapter(new AttributeAdapter(attributes));

    //Section ChildTypes
    sectionHeader = new TextView(getActivity());
    sectionHeader.setBackgroundColor(Color.DKGRAY);
    sectionHeader.setPadding(15, 10, 0, 10);
    sectionHeader.setText(R.string.child_types);
    adapter.addView(sectionHeader);

    childTypes = new ArrayList<ChildType>();
    adapter.addAdapter(new ChildTypeAdapter(childTypes));

    // Section Operations
    sectionHeader = new TextView(getActivity());
    sectionHeader.setBackgroundColor(Color.DKGRAY);
    sectionHeader.setPadding(15, 10, 0, 10);
    adapter.addView(sectionHeader);

    adapter.addAdapter(
            new IconTextRowAdapter(getActivity(), Arrays.asList("Operations"), R.drawable.ic_operations));

    setListAdapter(adapter);

    // inform runtime that we have action buttons
    setHasOptionsMenu(true);

    refresh();
}

From source file:com.konsula.app.gcm.MyGcmListenerService.java

private void handleGCM(Bundle bundle) {
    try {/*from   w  w  w  . jav a 2 s  .  c om*/
        Bundle data = bundle;
        String message = data.getString(TAG_MESSAGE, "");
        final String doc_name = data.getString(TAG_DOC_NAME, "");
        final String schedule = data.getString(TAG_SCHEDULE, "");
        final String specialization = data.getString(TAG_SPECIALIZATION, "");
        final String status = data.getString(TAG_STATUS, "");
        String tele_uuid = data.getString(TAG_TELE_UUID, "");
        String page = data.getString(TAG_PAGE, "");
        String type = data.getString(TAG_TYPE, "");
        if (type.equals("dialog")) {
            if (page.equals("teledoc-confirmed")) {
                CustomAlertDialogBuilder builder = new CustomAlertDialogBuilder(this,
                        getResources().getColor(R.color.green_xxl));
                View invoiceDetail = LayoutInflater.from(this).inflate(R.layout.dialog_teledoc_confirm, null);
                TextView textViewname = (TextView) invoiceDetail.findViewById(R.id.tvNamaDokter);
                TextView textViewspeciality = (TextView) invoiceDetail.findViewById(R.id.etSpeciality);
                TextView textViewdate = (TextView) invoiceDetail.findViewById(R.id.tvDate);
                TextView textViewstatus = (TextView) invoiceDetail.findViewById(R.id.text_status);
                TextView btnCancel = (TextView) invoiceDetail.findViewById(R.id.positive_button);
                btnCancel.setBackgroundColor(getResources().getColor(R.color.green_xxl));
                btnCancel.setText(getResources().getString(R.string.mdtp_ok));
                btnCancel.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog.dismiss();
                    }
                });
                textViewname.setText(doc_name);
                textViewspeciality.setText(specialization);
                textViewdate.setText(schedule);
                textViewstatus.setText(status.toUpperCase());
                builder.setView(invoiceDetail);
                builder.setTitle(getResources().getString(R.string.title_teledokter));
                dialog = builder.create();
                dialog.setOnShowListener(new DialogInterface.OnShowListener() {
                    @Override
                    public void onShow(DialogInterface dialog) {
                        // TODO Auto-generated method stub
                        Dialog d = ((Dialog) dialog);

                        int dividerId = d.getContext().getResources().getIdentifier("android:id/titleDivider",
                                null, null);
                        View divider = d.findViewById(dividerId);
                        if (divider != null) {
                            divider.setBackgroundColor(getResources().getColor(R.color.green_xxl));
                        }
                    }
                });
                dialog.show();
            }
            if (page.equals("teledoc-cancel")) {
                CustomAlertDialogBuilder builder = new CustomAlertDialogBuilder(this,
                        getResources().getColor(R.color.green_xxl));
                View invoiceDetail = LayoutInflater.from(this).inflate(R.layout.dialog_teledoc_cancel_confirm,
                        null);
                TextView textView = (TextView) invoiceDetail.findViewById(R.id.message);
                TextView btnCancel = (TextView) invoiceDetail.findViewById(R.id.positive_button);
                btnCancel.setBackgroundColor(getResources().getColor(R.color.green_xxl));
                btnCancel.setText(getResources().getString(R.string.mdtp_ok));
                btnCancel.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog.dismiss();
                    }
                });
                textView.setText(getResources().getString(R.string.text_teledoc_cancel));
                builder.setView(invoiceDetail);
                builder.setTitle(getResources().getString(R.string.title_teledokter));
                dialog = builder.create();
                dialog.setOnShowListener(new DialogInterface.OnShowListener() {
                    @Override
                    public void onShow(DialogInterface dialog) {
                        // TODO Auto-generated method stub
                        Dialog d = ((Dialog) dialog);

                        int dividerId = d.getContext().getResources().getIdentifier("android:id/titleDivider",
                                null, null);
                        View divider = d.findViewById(dividerId);
                        if (divider != null) {
                            divider.setBackgroundColor(getResources().getColor(R.color.green_xxl));
                        }
                    }
                });
                dialog.show();
            }
            if (page.equals("teledoc-reschedule")) {
                CustomAlertDialogBuilder builder = new CustomAlertDialogBuilder(this,
                        getResources().getColor(R.color.green_xxl));
                View invoiceDetail = LayoutInflater.from(this).inflate(R.layout.dialog_teledoc_cancel_confirm,
                        null);
                TextView textView = (TextView) invoiceDetail.findViewById(R.id.message);
                TextView btnCancel = (TextView) invoiceDetail.findViewById(R.id.positive_button);
                btnCancel.setBackgroundColor(getResources().getColor(R.color.green_xxl));
                btnCancel.setText(getResources().getString(R.string.mdtp_ok));
                btnCancel.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog.dismiss();
                    }
                });
                textView.setText(getResources().getString(R.string.text_reschedule_information));
                builder.setView(invoiceDetail);
                builder.setTitle(getResources().getString(R.string.title_teledokter));
                dialog = builder.create();
                dialog.setOnShowListener(new DialogInterface.OnShowListener() {
                    @Override
                    public void onShow(DialogInterface dialog) {
                        // TODO Auto-generated method stub
                        Dialog d = ((Dialog) dialog);

                        int dividerId = d.getContext().getResources().getIdentifier("android:id/titleDivider",
                                null, null);
                        View divider = d.findViewById(dividerId);
                        if (divider != null) {
                            divider.setBackgroundColor(getResources().getColor(R.color.green_xxl));
                        }
                    }
                });
                dialog.show();
            }
        } else if (type.equals("intent") && (page.equals("teledoc-confirmation-reschedule"))) {
            Intent intent = new Intent(this, TeledocRescheduleActivity.class);
            intent.putExtra(TeledocRescheduleActivity.TAG_TELE_UUID, tele_uuid);
            intent.putExtra(TeledocRescheduleActivity.TAG_DOC_NAME, doc_name);
            intent.putExtra(TeledocRescheduleActivity.TAG_DOC_SPECIALIZATION, specialization);
            intent.putExtra(TeledocRescheduleActivity.TAG_DOC_SCHEDULE, schedule);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
        }

    } catch (Exception e) {
        Log.e("ee", e.getMessage());
        Log.e("ee", String.valueOf(e));

    }
}

From source file:org.odk.collect.android.fragments.AppListFragment.java

private void setupDrawerItems() {
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(getContext(), android.R.layout.simple_list_item_1,
            sortingOptions) {//from   w  ww.ja va 2s.  c om
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            TextView textView = (TextView) super.getView(position, convertView, parent);
            if (position == getSelectedSortingOrder()) {
                textView.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.light_blue));
            }
            textView.setPadding(50, 0, 0, 0);
            return textView;
        }
    };
    drawerList.setAdapter(adapter);
    drawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            parent.getChildAt(selectedSortingOrder).setBackgroundColor(Color.TRANSPARENT);
            view.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.light_blue));
            performSelectedSearch(position);
            drawerLayout.closeDrawer(Gravity.END);
        }
    });
}

From source file:org.nuxeo.android.layout.WidgetDefinition.java

public NuxeoWidget build(LayoutContext context, Document doc, ViewGroup parent, LayoutMode mode) {
    this.mode = mode;

    View view = null;/* w w  w. ja  v a2  s .  c o  m*/
    LayoutParams labelLayoutParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT, 1f);
    LayoutParams widgetLayoutParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT, 1f);

    if (LayoutMode.VIEW == mode) {
        labelLayoutParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT,
                0.6f);
        widgetLayoutParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT,
                0.4f);
    }

    AndroidWidgetWrapper wrapper = AndroidWidgetMapper.getInstance().getWidgetWrapper(this);

    if (wrapper != null) {
        view = wrapper.buildView(context, mode, doc, attributeNames, this);
        view.setLayoutParams(widgetLayoutParams);
        view.setPadding(1, 1, 1, 1);
        if (LayoutMode.VIEW == mode) {
            view.setBackgroundColor(Color.rgb(240, 240, 250));
        }
    }

    if (view != null) {
        if (label != null) {
            TextView labelW = new TextView(context.getActivity());
            labelW.setText(label + " :");
            labelW.setTextColor(Color.rgb(80, 80, 80));
            labelW.setLayoutParams(labelLayoutParams);
            parent.addView(labelW);
            if (LayoutMode.VIEW != mode) {
                labelW.setBackgroundColor(Color.rgb(160, 160, 170));
                labelW.setTextColor(Color.rgb(20, 20, 40));
                labelW.setPadding(5, 5, 5, 5);
            }

        }
        parent.addView(view);
        return new NuxeoWidget(this, view, wrapper);
    }

    return null;
}

From source file:org.kaaproject.kaa.demo.notification.fragment.NotificationDialogFragment.java

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    TextView topicName = ((TextView) view.findViewById(R.id.popup_topic));
    TextView message = ((TextView) view.findViewById(R.id.popup_notification));
    TextView logo = ((TextView) view.findViewById(R.id.popup_type));

    Button okButton = (Button) view.findViewById(R.id.popup_ok);
    okButton.setOnClickListener(new View.OnClickListener() {
        @Override/*from   www .j  a va2s. c  om*/
        public void onClick(View v) {
            dismiss();
        }
    });

    message.setText(notificationMessage);
    topicName.setText(this.topicName);
    logo.setBackgroundColor(getActivity().getResources().getColor(getColorId()));
}

From source file:org.totschnig.myexpenses.dialog.TransactionDetailFragment.java

public void fillData(Transaction o) {
    final FragmentActivity ctx = getActivity();
    mLayout.findViewById(R.id.progress).setVisibility(View.GONE);
    mTransaction = o;//  w ww .j  av  a  2 s. co  m
    if (mTransaction == null) {
        TextView error = (TextView) mLayout.findViewById(R.id.error);
        error.setVisibility(View.VISIBLE);
        error.setText(R.string.transaction_deleted);
        return;
    }
    boolean doShowPicture = false;
    if (mTransaction.getPictureUri() != null) {
        doShowPicture = true;
        if (mTransaction.getPictureUri().getScheme().equals("file")) {
            if (!new File(mTransaction.getPictureUri().getPath()).exists()) {
                Toast.makeText(getActivity(), R.string.image_deleted, Toast.LENGTH_SHORT).show();
                doShowPicture = false;
            }
        }
    }
    AlertDialog dlg = (AlertDialog) getDialog();
    if (dlg != null) {
        Button btn = dlg.getButton(AlertDialog.BUTTON_POSITIVE);
        if (btn != null) {
            if (mTransaction.crStatus != Transaction.CrStatus.VOID) {
                btn.setEnabled(true);
            } else {
                btn.setVisibility(View.GONE);
            }
        }
        btn = dlg.getButton(AlertDialog.BUTTON_NEUTRAL);
        if (btn != null) {
            btn.setVisibility(doShowPicture ? View.VISIBLE : View.GONE);
        }
    }
    mLayout.findViewById(R.id.Table).setVisibility(View.VISIBLE);
    int title;
    boolean type = mTransaction.getAmount().getAmountMinor() > 0 ? ExpenseEdit.INCOME : ExpenseEdit.EXPENSE;

    if (mTransaction instanceof SplitTransaction) {
        mLayout.findViewById(R.id.SplitContainer).setVisibility(View.VISIBLE);
        //TODO: refactor duplicated code with SplitPartList
        title = R.string.split_transaction;
        View emptyView = mLayout.findViewById(R.id.empty);

        ListView lv = (ListView) mLayout.findViewById(R.id.list);
        // Create an array to specify the fields we want to display in the list
        String[] from = new String[] { KEY_LABEL_MAIN, KEY_AMOUNT };

        // and an array of the fields we want to bind those fields to 
        int[] to = new int[] { R.id.category, R.id.amount };

        // Now create a simple cursor adapter and set it to display
        mAdapter = new SplitPartAdapter(ctx, R.layout.split_part_row, null, from, to, 0,
                mTransaction.getAmount().getCurrency());
        lv.setAdapter(mAdapter);
        lv.setEmptyView(emptyView);

        LoaderManager manager = getLoaderManager();
        if (manager.getLoader(SPLIT_PART_CURSOR) != null && !manager.getLoader(SPLIT_PART_CURSOR).isReset()) {
            manager.restartLoader(SPLIT_PART_CURSOR, null, this);
        } else {
            manager.initLoader(SPLIT_PART_CURSOR, null, this);
        }

    } else {
        if (mTransaction instanceof Transfer) {
            title = R.string.transfer;
            ((TextView) mLayout.findViewById(R.id.AccountLabel)).setText(R.string.transfer_from_account);
            ((TextView) mLayout.findViewById(R.id.CategoryLabel)).setText(R.string.transfer_to_account);
        } else {
            title = type ? R.string.income : R.string.expense;
        }
    }

    String amountText;
    String accountLabel = Account.getInstanceFromDb(mTransaction.accountId).label;
    if (mTransaction instanceof Transfer) {
        ((TextView) mLayout.findViewById(R.id.Account)).setText(type ? mTransaction.label : accountLabel);
        ((TextView) mLayout.findViewById(R.id.Category)).setText(type ? accountLabel : mTransaction.label);
        if (((Transfer) mTransaction).isSameCurrency()) {
            amountText = formatCurrencyAbs(mTransaction.getAmount());
        } else {
            String self = formatCurrencyAbs(mTransaction.getAmount());
            String other = formatCurrencyAbs(mTransaction.getTransferAmount());
            amountText = type == ExpenseEdit.EXPENSE ? (self + " => " + other) : (other + " => " + self);
        }
    } else {
        ((TextView) mLayout.findViewById(R.id.Account)).setText(accountLabel);
        if ((mTransaction.getCatId() != null && mTransaction.getCatId() > 0)) {
            ((TextView) mLayout.findViewById(R.id.Category)).setText(mTransaction.label);
        } else {
            mLayout.findViewById(R.id.CategoryRow).setVisibility(View.GONE);
        }
        amountText = formatCurrencyAbs(mTransaction.getAmount());
    }

    //noinspection SetTextI18n
    ((TextView) mLayout.findViewById(R.id.Date))
            .setText(DateFormat.getDateInstance(DateFormat.FULL).format(mTransaction.getDate()) + " "
                    + DateFormat.getTimeInstance(DateFormat.SHORT).format(mTransaction.getDate()));

    ((TextView) mLayout.findViewById(R.id.Amount)).setText(amountText);

    if (!mTransaction.comment.equals("")) {
        ((TextView) mLayout.findViewById(R.id.Comment)).setText(mTransaction.comment);
    } else {
        mLayout.findViewById(R.id.CommentRow).setVisibility(View.GONE);
    }

    if (!mTransaction.referenceNumber.equals("")) {
        ((TextView) mLayout.findViewById(R.id.Number)).setText(mTransaction.referenceNumber);
    } else {
        mLayout.findViewById(R.id.NumberRow).setVisibility(View.GONE);
    }

    if (!mTransaction.payee.equals("")) {
        ((TextView) mLayout.findViewById(R.id.Payee)).setText(mTransaction.payee);
        ((TextView) mLayout.findViewById(R.id.PayeeLabel)).setText(type ? R.string.payer : R.string.payee);
    } else {
        mLayout.findViewById(R.id.PayeeRow).setVisibility(View.GONE);
    }

    if (mTransaction.methodId != null) {
        ((TextView) mLayout.findViewById(R.id.Method))
                .setText(PaymentMethod.getInstanceFromDb(mTransaction.methodId).getLabel());
    } else {
        mLayout.findViewById(R.id.MethodRow).setVisibility(View.GONE);
    }

    if (Account.getInstanceFromDb(mTransaction.accountId).type.equals(AccountType.CASH)) {
        mLayout.findViewById(R.id.StatusRow).setVisibility(View.GONE);
    } else {
        TextView tv = (TextView) mLayout.findViewById(R.id.Status);
        tv.setBackgroundColor(mTransaction.crStatus.color);
        tv.setText(mTransaction.crStatus.toString());
    }

    if (mTransaction.originTemplate == null) {
        mLayout.findViewById(R.id.PlannerRow).setVisibility(View.GONE);
    } else {
        ((TextView) mLayout.findViewById(R.id.Plan))
                .setText(mTransaction.originTemplate.getPlan() == null ? getString(R.string.plan_event_deleted)
                        : Plan.prettyTimeInfo(getActivity(), mTransaction.originTemplate.getPlan().rrule,
                                mTransaction.originTemplate.getPlan().dtstart));
    }

    dlg.setTitle(title);
    if (doShowPicture) {
        ImageView image = ((ImageView) dlg.getWindow().findViewById(android.R.id.icon));
        image.setVisibility(View.VISIBLE);
        image.setScaleType(ImageView.ScaleType.CENTER_CROP);
        Picasso.with(ctx).load(mTransaction.getPictureUri()).fit().into(image);
    }
}