Example usage for android.widget LinearLayout addView

List of usage examples for android.widget LinearLayout addView

Introduction

In this page you can find the example usage for android.widget LinearLayout addView.

Prototype

public void addView(View child) 

Source Link

Document

Adds a child view.

Usage

From source file:com.infigent.stocksense.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    startService(new Intent(this, BackGround.class));
    // setSlidingActionBarEnabled(true);
    Intent n = getIntent();/* ww w .j a va2  s .  c o m*/
    if (getIntent() != null) {
        Bundle bundle = n.getExtras();
        if (bundle != null) {
            Log.e("ARG", "EXIST");
            if (bundle.containsKey("eq")) {
                Log.e("EQ", "EXIST");
                if (bundle.getBoolean("eq")) {
                    Log.e("eq", "true");
                    Bundle data = new Bundle();
                    Fragment4 eq = new Fragment4();
                    mContent = eq;
                    data.putString("q", bundle.getString("q"));
                    data.putString("type", bundle.getString("type"));
                    data.putString("name", bundle.getString("name"));
                    data.putString("f", gId());
                    eq.setArguments(data);
                    switchContent(eq);
                }
            }
        }
    }

    if (savedInstanceState != null)
        mContent = getSupportFragmentManager().getFragment(savedInstanceState, "mContent");
    if (mContent == null)
        mContent = new Fragment1();

    ScrollView scrollView = new ScrollView(this);
    LinearLayout l = new LinearLayout(this);
    TextView one = new TextView(this);
    one.setText(getResources().getString(R.string.intro));
    one.setPadding(0, 0, 0, 20);
    TextView two = new TextView(this);
    two.setText("Limited License");
    two.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_DeviceDefault_Medium);
    TextView three = new TextView(this);
    three.setText(getResources().getString(R.string.l1));
    TextView four = new TextView(this);
    four.setText(getResources().getString(R.string.l2));
    four.setPadding(0, 0, 0, 20);
    TextView five = new TextView(this);
    five.setText("Disclaimer");
    five.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_DeviceDefault_Medium);
    TextView six = new TextView(this);
    six.setText(getResources().getString(R.string.disclaimer1));
    TextView seven = new TextView(this);
    seven.setText(getResources().getString(R.string.disclaimer2));
    TextView eight = new TextView(this);
    eight.setText(getResources().getString(R.string.disclaimer3));
    eight.setPadding(0, 0, 0, 20);
    TextView nine = new TextView(this);
    nine.setText("Liability For Our Services");
    nine.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_DeviceDefault_Medium);
    TextView ten = new TextView(this);
    ten.setText(getResources().getString(R.string.liability1));
    TextView eleven = new TextView(this);
    eleven.setText(getResources().getString(R.string.liability2));
    eleven.setPadding(0, 0, 0, 20);
    TextView twelve = new TextView(this);
    twelve.setText("Maintenance And Support");
    twelve.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_DeviceDefault_Medium);
    TextView thirteen = new TextView(this);
    thirteen.setText(getResources().getString(R.string.ms));
    thirteen.setPadding(0, 0, 0, 20);
    TextView fourteen = new TextView(this);
    fourteen.setText("Links To Third Party Website");
    fourteen.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_DeviceDefault_Medium);
    TextView fifteen = new TextView(this);
    fifteen.setText(getResources().getString(R.string.p3));
    l.addView(one);
    l.addView(two);
    l.addView(three);
    l.addView(four);
    l.addView(five);
    l.addView(six);
    l.addView(seven);
    l.addView(eight);
    l.addView(nine);
    l.addView(ten);
    l.addView(eleven);
    l.addView(twelve);
    l.addView(thirteen);
    l.addView(fourteen);
    l.addView(fifteen);
    one.setTextColor(getResources().getColor(R.color.White));
    two.setTextColor(getResources().getColor(R.color.White));
    three.setTextColor(getResources().getColor(R.color.White));
    four.setTextColor(getResources().getColor(R.color.White));
    five.setTextColor(getResources().getColor(R.color.White));
    six.setTextColor(getResources().getColor(R.color.White));
    seven.setTextColor(getResources().getColor(R.color.White));
    eight.setTextColor(getResources().getColor(R.color.White));
    nine.setTextColor(getResources().getColor(R.color.White));
    ten.setTextColor(getResources().getColor(R.color.White));
    eleven.setTextColor(getResources().getColor(R.color.White));
    twelve.setTextColor(getResources().getColor(R.color.White));
    thirteen.setTextColor(getResources().getColor(R.color.White));
    fourteen.setTextColor(getResources().getColor(R.color.White));
    fifteen.setTextColor(getResources().getColor(R.color.White));
    l.setOrientation(LinearLayout.VERTICAL);
    l.setBackgroundColor(getResources().getColor(R.color.bg));
    l.setPadding(10, 10, 10, 10);
    scrollView.addView(l);
    boolean firstboot = getSharedPreferences("BOOT_PREF", MODE_PRIVATE).getBoolean("firstboot", true);
    if (firstboot) {

        LayoutInflater inflater = getLayoutInflater();
        View vvv = inflater.inflate(R.layout.alerttitle, null);
        AlertDialog.Builder builder = new AlertDialog.Builder(this).setTitle("Terms of Service")
                .setView(scrollView).setCustomTitle(vvv)
                .setPositiveButton(android.R.string.ok, new Dialog.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        dialogInterface.dismiss();

                        getSharedPreferences("BOOT_PREF", MODE_PRIVATE).edit().putBoolean("firstboot", false)
                                .commit();
                    }
                }).setNegativeButton(android.R.string.cancel, new Dialog.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        // Close the activity as they have declined the EULA
                        MainActivity.this.finish();
                    }

                }).setCancelable(false);
        builder.create().show();
    }
    ime = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    ActionBar actionBar = getSupportActionBar();
    getSupportActionBar().setCustomView(R.layout.search);
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
    actionBar.setDisplayUseLogoEnabled(true);
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setDisplayShowHomeEnabled(true);
    actionBar.setDisplayHomeAsUpEnabled(true);
    sb = (ImageButton) actionBar.getCustomView().findViewById(R.id.sb);
    title = (TextView) actionBar.getCustomView().findViewById(R.id.title);
    sb.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            // only will trigger it if no physical keyboard is open
            search.setVisibility(View.VISIBLE);
            search.requestFocus();
            ime.showSoftInput(search, InputMethodManager.SHOW_IMPLICIT);
            search.setSelection(search.getText().length());
            sb.setVisibility(View.GONE);
            title.setVisibility(View.GONE);

        }
    });

    search = (AutoCompleteTextView) actionBar.getCustomView().findViewById(R.id.et);
    search.setThreshold(2);
    search.setAdapter(new SuggestionsAdapter(this, search.getText().toString()));
    search.setSelectAllOnFocus(true);
    search.clearFocus();

    search.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View arg1, int pos, long id) {
            String term = parent.getItemAtPosition(pos).toString();
            String[] lines = term.split("\\r?\\n");
            String name = lines[0];
            String code = lines[1].substring(lines[1].indexOf(":") + 1, lines[1].length()).trim();
            String type = lines[1].substring(0, lines[1].indexOf(":"));
            Log.d("DATA", name + " " + type + ":" + code);
            search.setText("");
            if (isNetworkAvailable()) {
                if (term.replace(" ", "") != null) {
                    Bundle data = new Bundle();
                    data.putString("q", code);
                    data.putString("type", type);
                    data.putString("name", name);
                    data.putString("f", gId());
                    Fragment4 eq = new Fragment4();
                    eq.setArguments(data);
                    Log.d("C", gId() + " frag");
                    mContent = eq;
                    getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, eq).commit();
                    getSlidingMenu().showContent();
                    search.setVisibility(View.GONE);
                    sb.setVisibility(View.VISIBLE);
                    title.setVisibility(View.VISIBLE);
                    ime.hideSoftInputFromWindow(search.getApplicationWindowToken(), 0);
                } else {
                    Toast.makeText(getApplicationContext(), "Enter a search term!", Toast.LENGTH_LONG).show();
                }
            } else
                Toast.makeText(getApplicationContext(), "Internet not available", Toast.LENGTH_LONG).show();
        }
    });

    search.setOnEditorActionListener(new OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {

            return false;
        }
    });

    // set the Above View
    setContentView(R.layout.content_frame);
    getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, mContent).commit();
    AdView mAdView;
    mAdView = (AdView) findViewById(R.id.adView);
    AdRequest adRequest = new AdRequest.Builder().build();
    mAdView.loadAd(adRequest);
    // set the Behind View
    setBehindContentView(R.layout.menu_frame);
    getSupportFragmentManager().beginTransaction().replace(R.id.menu_frame, new SampleListFragment()).commit();
}

From source file:com.citrus.sample.WalletPaymentFragment.java

private void showCashoutPrompt() {
    final AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
    String message = "Please enter account details.";
    String positiveButtonText = "Withdraw";

    LinearLayout linearLayout = new LinearLayout(getActivity());
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    final TextView labelAmount = new TextView(getActivity());
    final EditText editAmount = new EditText(getActivity());
    final TextView labelAccountNo = new TextView(getActivity());
    final EditText editAccountNo = new EditText(getActivity());
    editAccountNo.setSingleLine(true);/*from   www.j a  v a  2s . c o  m*/
    final TextView labelAccountHolderName = new TextView(getActivity());
    final EditText editAccountHolderName = new EditText(getActivity());
    editAccountHolderName.setSingleLine(true);
    final TextView labelIfscCode = new TextView(getActivity());
    final EditText editIfscCode = new EditText(getActivity());
    editIfscCode.setSingleLine(true);

    labelAmount.setText("Withdrawal Amount");
    labelAccountNo.setText("Account Number");
    labelAccountHolderName.setText("Account Holder Name");
    labelIfscCode.setText("IFSC Code");

    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);

    labelAmount.setLayoutParams(layoutParams);
    labelAccountNo.setLayoutParams(layoutParams);
    labelAccountHolderName.setLayoutParams(layoutParams);
    labelIfscCode.setLayoutParams(layoutParams);
    editAmount.setLayoutParams(layoutParams);
    editAccountNo.setLayoutParams(layoutParams);
    editAccountHolderName.setLayoutParams(layoutParams);
    editIfscCode.setLayoutParams(layoutParams);

    linearLayout.addView(labelAmount);
    linearLayout.addView(editAmount);
    linearLayout.addView(labelAccountNo);
    linearLayout.addView(editAccountNo);
    linearLayout.addView(labelAccountHolderName);
    linearLayout.addView(editAccountHolderName);
    linearLayout.addView(labelIfscCode);
    linearLayout.addView(editIfscCode);

    int paddingPx = Utils.getSizeInPx(getActivity(), 32);
    linearLayout.setPadding(paddingPx, paddingPx, paddingPx, paddingPx);

    editAmount.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);

    alert.setTitle("Withdraw Money To Your Account");
    alert.setMessage(message);

    alert.setView(linearLayout);
    alert.setPositiveButton(positiveButtonText, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int whichButton) {
            String amount = editAmount.getText().toString();
            String accontNo = editAccountNo.getText().toString();
            String accountHolderName = editAccountHolderName.getText().toString();
            String ifsc = editIfscCode.getText().toString();

            CashoutInfo cashoutInfo = new CashoutInfo(new Amount(amount), accontNo, accountHolderName, ifsc);
            mListener.onCashoutSelected(cashoutInfo);

            // Hide the keyboard.
            InputMethodManager imm = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(editAmount.getWindowToken(), 0);
        }
    });

    alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            dialog.cancel();
        }
    });

    editAmount.requestFocus();
    alert.show();
}

From source file:com.citrus.sample.WalletPaymentFragment.java

private void showUpdateSubscriptionPrompt(final boolean isUpdateToHigherValue) {
    final AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
    //    final String message = "Update Subscription to Lowe Amount";
    String positiveButtonText = "Update Subscription ";

    LinearLayout linearLayout = new LinearLayout(getActivity());
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    final TextView labelsubscriptionID = new TextView(getActivity());
    final EditText edtAmount = new EditText(getActivity());
    final TextView labelAmount = new TextView(getActivity());
    final EditText editLoadAmount = new EditText(getActivity());
    final TextView labelMobileNo = new TextView(getActivity());
    final EditText editThresholdAmount = new EditText(getActivity());

    editLoadAmount.setSingleLine(true);/*from  w  w  w . j a  v  a 2s.  c  o m*/
    editThresholdAmount.setSingleLine(true);
    edtAmount.setSingleLine(true);
    edtAmount.setInputType(InputType.TYPE_NULL);
    labelsubscriptionID.setText("Load Money Amount");
    labelAmount.setText("Current Auto Load Amount");
    editLoadAmount.setText(String.valueOf(activeSubscription.getLoadAmount()));
    labelMobileNo.setText("Current Threshold Amount");
    editThresholdAmount.setText(String.valueOf(activeSubscription.getThresholdAmount()));

    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);

    labelsubscriptionID.setLayoutParams(layoutParams);
    edtAmount.setLayoutParams(layoutParams);
    labelAmount.setLayoutParams(layoutParams);
    labelMobileNo.setLayoutParams(layoutParams);
    editLoadAmount.setLayoutParams(layoutParams);
    editThresholdAmount.setLayoutParams(layoutParams);

    linearLayout.addView(labelAmount);
    linearLayout.addView(editLoadAmount);
    linearLayout.addView(labelMobileNo);
    linearLayout.addView(editThresholdAmount);
    linearLayout.addView(labelsubscriptionID);
    linearLayout.addView(edtAmount);
    edtAmount.setText("1.00");

    int paddingPx = Utils.getSizeInPx(getActivity(), 32);
    linearLayout.setPadding(paddingPx, paddingPx, paddingPx, paddingPx);

    editLoadAmount.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
    edtAmount.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
    editLoadAmount.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            /* if (!hasFocus) {
            if (Double.valueOf(editLoadAmount.getText().toString()) > activeSubscription.getLoadAmount()) {
                labelsubscriptionID.setVisibility(View.VISIBLE);
                edtAmount.setVisibility(View.VISIBLE);
                edtAmount.setText("1.00");
                    
            } else {
                labelsubscriptionID.setVisibility(View.INVISIBLE);
                edtAmount.setVisibility(View.INVISIBLE);
            }
             }*/
        }
    });
    editThresholdAmount.setInputType(InputType.TYPE_CLASS_NUMBER);
    alert.setTitle("Update Subscription ");
    alert.setMessage("Updating Load amount to higher will require Load Money transactions.");

    alert.setView(linearLayout);
    alert.setPositiveButton(positiveButtonText, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int whichButton) {
            final String trAmount = edtAmount.getText().toString();

            final String loadAmount = editLoadAmount.getText().toString();
            final String thresHoldAmount = editThresholdAmount.getText().toString();

            // Hide the keyboard.
            InputMethodManager imm = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(edtAmount.getWindowToken(), 0);

            if (TextUtils.isEmpty(trAmount) && edtAmount.getVisibility() == View.VISIBLE) {
                Toast.makeText(getActivity(), " load amount cant be blank", Toast.LENGTH_SHORT).show();
                return;
            }

            if (TextUtils.isEmpty(loadAmount)) {
                Toast.makeText(getActivity(), "Auto Load Amount cant be blank", Toast.LENGTH_SHORT).show();
                return;
            }

            if (TextUtils.isEmpty(thresHoldAmount)) {
                Toast.makeText(getActivity(), "thresHoldAmount cant be blank", Toast.LENGTH_SHORT).show();
                return;
            }

            if (Double.valueOf(thresHoldAmount) < new Double("500")) {
                Toast.makeText(getActivity(), "thresHoldAmount  should not be less than 500",
                        Toast.LENGTH_SHORT).show();
                return;
            }

            if (Double.valueOf(loadAmount) < new Double(thresHoldAmount)) {
                Toast.makeText(getActivity(), "Load Amount should not be less than thresHoldAmount",
                        Toast.LENGTH_SHORT).show();
                return;
            }
            if (Double.valueOf(editLoadAmount.getText().toString()) > activeSubscription.getLoadAmount()) { //update to higher value
                mListener.onAutoLoadSelected(AUTO_LOAD_MONEY, new Amount(trAmount),
                        editLoadAmount.getText().toString(), editThresholdAmount.getText().toString(), true);
            } else { //update to lower value
                mCitrusClient.updateSubScriptiontoLoweValue(new Amount(thresHoldAmount), new Amount(loadAmount),
                        new Callback<SubscriptionResponse>() {
                            @Override
                            public void success(SubscriptionResponse subscriptionResponse) {
                                Toast.makeText(getActivity(), subscriptionResponse.toString(),
                                        Toast.LENGTH_SHORT).show();

                                Logger.d("updateSubscription response **" + subscriptionResponse.toString());
                                activeSubscription = subscriptionResponse;//update the active subscription Object
                            }

                            @Override
                            public void error(CitrusError error) {
                                Toast.makeText(getActivity(), error.getMessage(), Toast.LENGTH_SHORT).show();
                                Logger.d("ERROR ***updateSubscription" + error.getMessage());
                            }
                        });
            }
        }
    });

    alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            dialog.cancel();
        }
    });

    editLoadAmount.requestFocus();
    alert.show();
}

From source file:com.brq.wallet.activity.modern.AccountsFragment.java

private void update() {
    if (!isAdded()) {
        return;/*from   ww w  .j  a  va  2s .c  om*/
    }
    LinearLayout llRecords = (LinearLayout) getView().findViewById(R.id.llRecords);
    llRecords.removeAllViews();

    if (_mbwManager.isKeyManagementLocked()) {
        // Key management is locked
        getView().findViewById(R.id.svRecords).setVisibility(View.GONE);
        getView().findViewById(R.id.llLocked).setVisibility(View.VISIBLE);
    } else {
        // Make all the key management functionality available to experts
        getView().findViewById(R.id.svRecords).setVisibility(View.VISIBLE);
        getView().findViewById(R.id.llLocked).setVisibility(View.GONE);

        List<WalletAccount> activeHdAccounts = walletManager.getActiveMasterseedAccounts();
        List<WalletAccount> activeOtherAccounts = walletManager.getActiveOtherAccounts();

        List<WalletAccount> activeHdRecords = Utils.sortAccounts(activeHdAccounts, _storage);
        List<WalletAccount> activeOtherRecords = Utils.sortAccounts(activeOtherAccounts, _storage);
        List<WalletAccount> archivedRecords = Utils.sortAccounts(walletManager.getArchivedAccounts(), _storage);

        WalletAccount selectedAccount = _mbwManager.getSelectedAccount();

        CurrencySum totalSpendableBalance = new CurrencySum();
        String activeTitle = getString(R.string.active_hd_accounts_name)
                + (activeHdRecords.isEmpty() ? " " + getString(R.string.active_accounts_empty) : "");
        CurrencySum spendableBalanceHdAccounts = getSpendableBalance(activeHdAccounts);
        LinearLayout activeHdAccountsView = createAccountViewList(activeTitle, activeHdRecords, selectedAccount,
                spendableBalanceHdAccounts);
        llRecords.addView(activeHdAccountsView);

        totalSpendableBalance.add(spendableBalanceHdAccounts);

        if (!activeOtherRecords.isEmpty()) {
            CurrencySum spendableBalanceOtherAccounts = getSpendableBalance(activeOtherAccounts);
            LinearLayout activeOtherAccountsView = createAccountViewList(
                    getString(R.string.active_other_accounts_name), activeOtherRecords, selectedAccount,
                    spendableBalanceOtherAccounts);
            llRecords.addView(activeOtherAccountsView);

            totalSpendableBalance.add(spendableBalanceOtherAccounts);

            // only show a totals row, if both account type exits
            LinearLayout activeOtherSum = createActiveAccountBalanceSumView(totalSpendableBalance);
            llRecords.addView(activeOtherSum);
        }

        if (archivedRecords.size() > 0) {
            LinearLayout archived = createAccountViewList(getString(R.string.archive_name), archivedRecords,
                    selectedAccount, null);
            llRecords.addView(archived);
        }
    }
}

From source file:com.example.android.recyclingbanks.MainActivity.java

private View prepareInfoView(final Marker marker) {
    // TODO change this to xml?
    //prepare InfoView programmatically
    final LinearLayout infoView = new LinearLayout(MainActivity.this);
    LinearLayout.LayoutParams infoViewParams = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    infoView.setOrientation(LinearLayout.VERTICAL);
    // attach the above layout to the infoView
    infoView.setLayoutParams(infoViewParams);

    String markerLongitude = Double.toString(marker.getPosition().longitude);
    String markerLatitude = Double.toString(marker.getPosition().latitude);

    final String imageURL = "https://maps.googleapis.com/maps/api/streetview?size=" + "500x300&location="
            + markerLatitude + "," + markerLongitude + "&fov=120&heading=0&pitch=0";

    //create street view preview @ top
    ImageView streetViewPreviewIV = new ImageView(MainActivity.this);

    Log.wtf("comparing TAG", String.valueOf(marker.getTag()));

    if (marker.getTag() == null) {
        Log.i("prepareInfoView", "fetching image");
        Picasso.with(this).load(imageURL).fetch(new MarkerCallback(marker));
    } else {/*from  ww  w.ja va2  s  .co  m*/
        Log.wtf("prepareInfoView", "building info window");

        // this scales the image to match parents WIDTH?, but retain image's height??
        LinearLayout.LayoutParams streetViewImageViewParams = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
        streetViewPreviewIV.setLayoutParams(streetViewImageViewParams);
        // TODO upon conversion to xml, the imageView needs these to scale image to box
        // android:scaleType="fitStart"
        // android:adjustViewBounds="true"
        Picasso.with(MainActivity.this).load(imageURL).into(streetViewPreviewIV);
        infoView.addView(streetViewPreviewIV);
        //Log.wtf("prepareInfoView, marker tag set?", String.valueOf(marker.getTag()));
        //Picasso.with(this).setLoggingEnabled(true);
    }

    // create text boxes
    LinearLayout subInfoView = new LinearLayout(MainActivity.this);
    LinearLayout.LayoutParams subInfoViewParams = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    subInfoView.setOrientation(LinearLayout.VERTICAL);
    subInfoView.setLayoutParams(subInfoViewParams);

    TextView titleTextView = new TextView(MainActivity.this);
    titleTextView.setText(marker.getTitle());
    TextView snippetTextView = new TextView(MainActivity.this);
    snippetTextView.setText(marker.getSnippet());
    subInfoView.addView(titleTextView);
    subInfoView.addView(snippetTextView);
    infoView.addView(subInfoView);

    // add the image on the right
    ImageView streetViewIcon = new ImageView(MainActivity.this);
    // this scales the image to match parents height.
    LinearLayout.LayoutParams imageViewParams = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
    streetViewIcon.setLayoutParams(imageViewParams);
    Drawable drawable = ContextCompat.getDrawable(MainActivity.this, R.drawable.ic_streetview);
    streetViewIcon.setImageDrawable(drawable);
    infoView.addView(streetViewIcon);
    //Picasso.with(this).load(imageURL).into(streetViewPreviewIV, new MarkerCallback(marker));

    return infoView;
}

From source file:ch.uzh.supersede.feedbacklibrary.FeedbackActivity.java

private void initView() {
    allMechanismViews = new ArrayList<>();
    LayoutInflater layoutInflater = LayoutInflater.from(this);
    LinearLayout linearLayout = (LinearLayout) findViewById(
            R.id.supersede_feedbacklibrary_feedback_activity_layout);

    if (linearLayout != null) {
        for (int i = 0; i < allMechanisms.size(); ++i) {
            if (allMechanisms.get(i).isActive()) {
                MechanismView mechanismView = null;
                View view = null;
                String type = allMechanisms.get(i).getType();
                switch (type) {
                case Mechanism.ATTACHMENT_TYPE:
                    break;
                case Mechanism.AUDIO_TYPE:
                    mechanismView = new AudioMechanismView(layoutInflater, allMechanisms.get(i), getResources(),
                            this, getApplicationContext());
                    view = mechanismView.getEnclosingLayout();
                    break;
                case Mechanism.CATEGORY_TYPE:
                    mechanismView = new CategoryMechanismView(layoutInflater, allMechanisms.get(i));
                    view = mechanismView.getEnclosingLayout();
                    break;
                case Mechanism.RATING_TYPE:
                    mechanismView = new RatingMechanismView(layoutInflater, allMechanisms.get(i));
                    view = mechanismView.getEnclosingLayout();
                    break;
                case Mechanism.SCREENSHOT_TYPE:
                    mechanismView = new ScreenshotMechanismView(layoutInflater, allMechanisms.get(i), this,
                            allMechanismViews.size(), defaultImagePath);
                    view = mechanismView.getEnclosingLayout();
                    break;
                case Mechanism.TEXT_TYPE:
                    mechanismView = new TextMechanismView(layoutInflater, allMechanisms.get(i));
                    view = mechanismView.getEnclosingLayout();
                    break;
                default:
                    Log.wtf(TAG, "Unknown mechanism type '" + type + "'");
                    break;
                }//from  ww w  .j a  v a2 s.co  m

                if (mechanismView != null && view != null) {
                    allMechanismViews.add(mechanismView);
                    linearLayout.addView(view);
                }
            }
        }

        layoutInflater.inflate(R.layout.send_feedback_layout, linearLayout);
    }
}

From source file:com.phonegap.plugins.slaveBrowser.SlaveBrowser.java

/**
 * Display a new browser with the specified URL.
 *
 * @param url       The url to load.//  w  ww .j  a  v a2s  .  c  o  m
 * @param jsonObject 
 */
public String showWebPage(final String url, JSONObject options, String myNewTitle) {
    // Determine if we should hide the location bar.
    if (options != null) {
        showLocationBar = options.optBoolean("showLocationBar", true);
    }
    zeTitle = myNewTitle;

    // Create dialog in new thread 
    Runnable runnable = new Runnable() {
        public void run() {
            dialog = new Dialog(ctx.getContext());
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setCancelable(true);
            dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
                public void onDismiss(DialogInterface dialog) {
                    try {
                        JSONObject obj = new JSONObject();
                        obj.put("type", CLOSE_EVENT);
                        sendUpdate(obj, false);
                    } catch (JSONException e) {
                        Log.d(LOG_TAG, "Should never happen");
                    }
                }
            });

            LinearLayout.LayoutParams backParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT);
            LinearLayout.LayoutParams forwardParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT);
            LinearLayout.LayoutParams editParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT, 1.0f);
            LinearLayout.LayoutParams closeParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT);
            LinearLayout.LayoutParams wvParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
                    LayoutParams.FILL_PARENT);
            LinearLayout main = new LinearLayout(ctx.getContext());
            main.setOrientation(LinearLayout.VERTICAL);

            LinearLayout toolbar = new LinearLayout(ctx.getContext());
            toolbar.setOrientation(LinearLayout.HORIZONTAL);

            edittext = new TextView(ctx.getContext());
            edittext.setId(3);
            edittext.setSingleLine(true);
            edittext.setText(zeTitle);
            edittext.setTextSize(TypedValue.COMPLEX_UNIT_PX, 24);
            edittext.setGravity(Gravity.CENTER);
            edittext.setTextColor(Color.DKGRAY);
            edittext.setTypeface(Typeface.DEFAULT_BOLD);
            edittext.setLayoutParams(editParams);

            webview = new WebView(ctx.getContext());
            webview.getSettings().setJavaScriptEnabled(true);
            webview.getSettings().setBuiltInZoomControls(true);

            // dda: intercept calls to console.log
            webview.setWebChromeClient(new WebChromeClient() {
                public boolean onConsoleMessage(ConsoleMessage cmsg) {
                    // check secret prefix
                    if (cmsg.message().startsWith("MAGICHTML")) {
                        String msg = cmsg.message().substring(9); // strip off prefix
                        /* process HTML */
                        try {
                            JSONObject obj = new JSONObject();
                            obj.put("type", PAGE_LOADED);
                            obj.put("html", msg);
                            sendUpdate(obj, true);
                        } catch (JSONException e) {
                            Log.d(LOG_TAG, "This should never happen");
                        }
                        return true;
                    }
                    return false;
                }
            });

            // dda: inject the JavaScript on page load
            webview.setWebViewClient(new SlaveBrowserClient(edittext) {
                public void onPageFinished(WebView view, String address) {
                    // have the page spill its guts, with a secret prefix
                    view.loadUrl(
                            "javascript:console.log('MAGICHTML'+document.getElementsByTagName('html')[0].innerHTML);");
                }
            });

            webview.loadUrl(url);
            webview.setId(5);
            webview.setInitialScale(0);
            webview.setLayoutParams(wvParams);
            webview.requestFocus();
            webview.requestFocusFromTouch();

            toolbar.addView(edittext);

            if (getShowLocationBar()) {
                main.addView(toolbar);
            }
            main.addView(webview);

            WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
            lp.copyFrom(dialog.getWindow().getAttributes());
            lp.width = WindowManager.LayoutParams.FILL_PARENT;
            lp.height = WindowManager.LayoutParams.FILL_PARENT;

            dialog.setContentView(main);
            dialog.show();
            dialog.getWindow().setAttributes(lp);
        }

        private Bitmap loadDrawable(String filename) throws java.io.IOException {
            InputStream input = ctx.getAssets().open(filename);
            return BitmapFactory.decodeStream(input);
        }
    };
    this.ctx.runOnUiThread(runnable);
    return "";
}

From source file:com.mdlive.sav.MDLiveProviderDetails.java

private void setHorizontalScrollviewTimeslots(LinearLayout layout, String str_timeslot, int position,
        String physId) {//from   w ww . j av a2  s  .  c  o  m

    final int density = (int) getBaseContext().getResources().getDisplayMetrics().density;

    final Button myText = new Button(MDLiveProviderDetails.this);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        myText.setElevation(0f);
    }
    horizontalscrollview.setContentDescription("Horizontal ScrollView");
    myText.setTextColor(Color.GRAY);
    myText.setTextSize(16);
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    params.setMargins(4 * density, 4 * density, 4 * density, 4 * density);
    myText.setLayoutParams(params);
    myText.setGravity(Gravity.CENTER);
    myText.setBackgroundResource(R.drawable.timeslot_white_rounded_corner);
    myText.setClickable(true);
    myText.setTag(timeSlotListMap.get(position).get("appointment_type"));
    myText.setPadding(8 * density, 4 * density, 8 * density, 4 * density);
    myText.setText(TimeZoneUtils.getTimeFromTimestamp(str_timeslot, this));
    layout.addView(myText);
    if (str_appointmenttype.equalsIgnoreCase("video") || str_appointmenttype.equalsIgnoreCase("video or phone")
            && str_timeslot != null && !str_timeslot.equals("0")) {

        videoList.add(myText);
    }

    if (str_appointmenttype.equalsIgnoreCase("phone") || str_appointmenttype.equalsIgnoreCase("video or phone")
            && str_timeslot != null && !str_timeslot.equals("0")) {
        phoneList.add(myText);
    }

    clickForVideoOrPhoneTapReqFutureAction();
    clickEventForHorizontalText(myText, str_timeslot, physId);

}

From source file:com.google.samples.apps.iosched.ui.CurrentSessionActivity.java

private void buildLinksSection(Cursor cursor) {
    // Compile list of links (I/O live link, submit feedback, and normal links)
    ViewGroup linkContainer = (ViewGroup) findViewById(R.id.links_container);
    linkContainer.removeAllViews();/* w  w  w .  jav a  2 s . c  om*/

    // Build links section
    // the Object can be either a string URL or an Intent
    List<Pair<Integer, Object>> links = new ArrayList<Pair<Integer, Object>>();

    long currentTimeMillis = UIUtils.getCurrentTime(this);
    if (mHasLivestream && currentTimeMillis > mSessionStart && currentTimeMillis <= mSessionEnd) {
        links.add(new Pair<Integer, Object>(R.string.session_link_livestream, getWatchLiveIntent(this)));
    }

    // Add session feedback link, if appropriate
    if (!mAlreadyGaveFeedback && currentTimeMillis > mSessionEnd - Config.FEEDBACK_MILLIS_BEFORE_SESSION_END) {
        links.add(new Pair<Integer, Object>(R.string.session_feedback_submitlink, getFeedbackIntent()));
    }

    for (int i = 0; i < SessionsQuery.LINKS_INDICES.length; i++) {
        final String linkUrl = cursor.getString(SessionsQuery.LINKS_INDICES[i]);
        if (TextUtils.isEmpty(linkUrl)) {
            continue;
        }

        links.add(new Pair<Integer, Object>(SessionsQuery.LINKS_TITLES[i],
                new Intent(Intent.ACTION_VIEW, Uri.parse(linkUrl))
                        .addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET)));
    }

    // Render links
    if (links.size() > 0) {
        LayoutInflater inflater = LayoutInflater.from(this);
        int columns = getResources().getInteger(R.integer.links_columns);

        LinearLayout currentLinkRowView = null;
        for (int i = 0; i < links.size(); i++) {
            final Pair<Integer, Object> link = links.get(i);

            // Create link view
            TextView linkView = (TextView) inflater.inflate(R.layout.list_item_session_link, linkContainer,
                    false);
            if (link.first == R.string.session_feedback_submitlink) {
                mSubmitFeedbackView = linkView;
            }
            linkView.setText(getString(link.first));
            linkView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    fireLinkEvent(link.first);
                    Intent intent = null;
                    if (link.second instanceof Intent) {
                        intent = (Intent) link.second;
                    } else if (link.second instanceof String) {
                        intent = new Intent(Intent.ACTION_VIEW, Uri.parse((String) link.second))
                                .addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
                    }
                    try {
                        startActivity(intent);
                    } catch (ActivityNotFoundException ignored) {
                    }
                }
            });

            // Place it inside a container
            if (columns == 1) {
                linkContainer.addView(linkView);
            } else {
                // create a new link row
                if (i % columns == 0) {
                    currentLinkRowView = (LinearLayout) inflater.inflate(R.layout.include_link_row,
                            linkContainer, false);
                    currentLinkRowView.setWeightSum(columns);
                    linkContainer.addView(currentLinkRowView);
                }

                ((LinearLayout.LayoutParams) linkView.getLayoutParams()).width = 0;
                ((LinearLayout.LayoutParams) linkView.getLayoutParams()).weight = 1;
                currentLinkRowView.addView(linkView);
            }
        }

        findViewById(R.id.session_links_header).setVisibility(View.VISIBLE);
        findViewById(R.id.links_container).setVisibility(View.VISIBLE);

    } else {
        findViewById(R.id.session_links_header).setVisibility(View.GONE);
        findViewById(R.id.links_container).setVisibility(View.GONE);
    }

}

From source file:com.geecko.QuickLyric.AboutActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    int[] themes = new int[] { R.style.Theme_QuickLyric, R.style.Theme_QuickLyric_Red,
            R.style.Theme_QuickLyric_Purple, R.style.Theme_QuickLyric_Indigo, R.style.Theme_QuickLyric_Green,
            R.style.Theme_QuickLyric_Lime, R.style.Theme_QuickLyric_Brown, R.style.Theme_QuickLyric_Dark };
    int themeNum = Integer.valueOf(sharedPref.getString("pref_theme", "0"));
    boolean nightMode = sharedPref.getBoolean("pref_night_mode", false);
    if (nightMode && NightTimeVerifier.check(this))
        setTheme(R.style.Theme_QuickLyric_Night);
    else/*w w  w  . j  a  v  a  2  s .  co m*/
        setTheme(themes[themeNum]);
    TypedValue primaryColor = new TypedValue();
    getTheme().resolveAttribute(R.attr.colorPrimary, primaryColor, true);
    setStatusBarColor(null);

    LinearLayout linearLayout = new LinearLayout(this);
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    Toolbar toolbar = new Toolbar(this);
    toolbar.setTitle(R.string.pref_about);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        toolbar.setElevation(8f);
    toolbar.setBackgroundColor(primaryColor.data);
    toolbar.setTitleTextColor(Color.WHITE);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription(null, null,
                primaryColor.data);
        this.setTaskDescription(taskDescription);
    }

    View.OnClickListener productTourAction = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            setupDemoScreen();
        }
    };

    Element productTourElement = new Element().setTitle(getString(R.string.about_product_tour));
    productTourElement.setOnClickListener(productTourAction);
    Element crowdinElement = new Element().setTitle(getString(R.string.about_crowdin));
    crowdinElement
            .setIntent(new Intent(Intent.ACTION_VIEW, Uri.parse("https://crowdin.com/project/quicklyric")));
    Element ossLicensesElement = new Element().setTitle("Open Source Licenses");
    ossLicensesElement.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            WebView webView = new WebView(AboutActivity.this);
            String data = getResources().getString(R.string.open_source_librairies_licenses);
            webView.loadData(data, "text/html; charset=utf-8", "UTF-8");
            new AlertDialog.Builder(AboutActivity.this).setView(webView).show();
        }
    });
    Element tosElement = new Element().setTitle(getString(R.string.about_read_ToS));
    tosElement.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            WebView webView = new WebView(AboutActivity.this);
            String data = getResources().getString(R.string.QL_EULA);
            webView.loadData(data, "text/html; charset=utf-8", "UTF-8");
            new AlertDialog.Builder(AboutActivity.this).setView(webView).show();
        }
    });
    Element cookElement = new Element().setTitle("Icon Designer");
    cookElement.setIntent(new Intent(Intent.ACTION_VIEW, Uri.parse("https://cookicons.co/")));

    View aboutView = new AboutPage(this).setDescription("QuickLyric is made with love in Brussels, Belgium.") // FixMe
            .addEmail("contact@QuickLyric.be").addFacebook("QuickLyric").addGitHub("geecko86/QuickLyric")
            .addPlayStore("test").addTwitter("QuickLyric").addWebsite("http://www.quicklyric.be")
            .setImage(R.drawable.icon).addItem(productTourElement).addItem(crowdinElement).addItem(cookElement)
            .addItem(ossLicensesElement).addItem(tosElement).create();
    aboutView.setLayoutParams(new ScrollView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    linearLayout.addView(toolbar);
    linearLayout.addView(aboutView);
    setContentView(linearLayout);

    final Drawable upArrow;
    if (Build.VERSION.SDK_INT >= 21) {
        upArrow = getResources().getDrawable(R.drawable.abc_ic_ab_back_material);
        upArrow.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP);
    } else
        upArrow = getResources().getDrawable(R.drawable.ic_arrow_back);

    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeAsUpIndicator(upArrow);
}