Example usage for android.widget ScrollView addView

List of usage examples for android.widget ScrollView addView

Introduction

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

Prototype

@Override
    public void addView(View child) 

Source Link

Usage

From source file:com.adarshahd.indianrailinfo.donate.TrainDetails.java

private void createTableLayoutTrainAvailability() {

    if (mPage.contains("SORRY")) {
        TextView textViewTrnDtls = new TextView(mActivity);
        textViewTrnDtls.setText("Not a valid class, Please select a different class and try again.");
        textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large);
        textViewTrnDtls.setPadding(10, 10, 10, 10);
        textViewTrnDtls.setTextColor(Color.RED);
        mFrameLayout.removeAllViews();//from www.j  a v a 2s.  co  m
        mFrameLayout.addView(textViewTrnDtls);
        if (mDialog.isShowing()) {
            mDialog.cancel();
        }
        return;
    }

    if (mPage.contains("ISL Of")) {
        TextView textViewTrnDtls = new TextView(mActivity);
        textViewTrnDtls.setText("Station is not in ISL Of the Train. \nPlease modify the source/destination!");
        textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large);
        textViewTrnDtls.setPadding(10, 10, 10, 10);
        textViewTrnDtls.setTextColor(Color.RED);
        mFrameLayout.removeAllViews();
        mFrameLayout.addView(textViewTrnDtls);
        if (mDialog.isShowing()) {
            mDialog.cancel();
        }
        return;
    }

    if (mPage.contains("ERROR")) {
        TextView textViewTrnDtls = new TextView(mActivity);
        textViewTrnDtls.setText("Your request resulted in an error.\nPlease check!");
        textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large);
        textViewTrnDtls.setPadding(10, 10, 10, 10);
        textViewTrnDtls.setTextColor(Color.RED);
        mFrameLayout.removeAllViews();
        mFrameLayout.addView(textViewTrnDtls);
        if (mDialog.isShowing()) {
            mDialog.cancel();
        }
        return;
    }

    if (mPage.contains("Network Connectivity")) {
        TextView textViewTrnDtls = new TextView(mActivity);
        textViewTrnDtls.setText("Looks like the server is busy.\nPlease try later!");
        textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large);
        textViewTrnDtls.setPadding(10, 10, 10, 10);
        textViewTrnDtls.setTextColor(Color.RED);
        mFrameLayout.removeAllViews();
        mFrameLayout.addView(textViewTrnDtls);
        if (mDialog.isShowing()) {
            mDialog.cancel();
        }
        return;
    }

    if (mPage.contains("unavailable")) {
        TextView textViewTrnDtls = new TextView(mActivity);
        textViewTrnDtls.setText(
                "Response from server:\n\nYour request could not be processed now.\nPlease try again later!");
        textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large);
        textViewTrnDtls.setPadding(10, 10, 10, 10);
        textViewTrnDtls.setTextColor(Color.RED);
        mFrameLayout.removeAllViews();
        mFrameLayout.addView(textViewTrnDtls);
        if (mDialog.isShowing()) {
            mDialog.cancel();
        }
        return;
    }

    if (mDetails == null || !mDetails.getTrainNumber().equals(mTrainNumber)) {
        Iterator iterator = null;
        try {
            iterator = mElements.first().parent().parent().parent().getElementsByTag("tr").iterator();
        } catch (Exception e) {
            Log.i("TrainDetails", mPage);
            e.printStackTrace();
            return;
        }
        mListAv = new ArrayList<List<String>>();
        List<String> list;
        Element tmp;
        tmp = (Element) iterator.next();
        list = new ArrayList<String>();
        list.add(tmp.select("th").get(0).text());
        list.add("Date");
        list.add(tmp.select("th").get(2).text());
        //list.add(tmp.select("th").get(3).text());
        mListAv.add(list);
        while (iterator.hasNext()) {
            tmp = (Element) iterator.next();
            if (!tmp.hasText()) {
                continue;
            }
            list = new ArrayList<String>();
            list.add(tmp.select("td").get(0).text());
            list.add(tmp.select("td").get(1).text());
            list.add(tmp.select("td").get(2).text());
            //list.add(tmp.select("td").get(3).text());
            mListAv.add(list);
        }
        mDetails = new Details(mListAv, TrainEnquiry.AVAILABILITY, mTrainNumber);
    } else {
        mListAv = mDetails.getList();
    }
    mTblLayoutAv = new TableLayout(mActivity);
    TableRow row;
    TextView tv1, tv2, tv3;
    mTblLayoutAv.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    for (int i = 0; i < mListAv.size(); i++) {
        row = new TableRow(mActivity);
        tv1 = new TextView(mActivity);
        tv2 = new TextView(mActivity);
        tv3 = new TextView(mActivity);
        //tv4 = new TextView(mActivity);

        tv1.setText("   " + mListAv.get(i).get(0));
        tv2.setText("   " + mListAv.get(i).get(1));
        tv3.setText("   " + mListAv.get(i).get(2));
        //tv4.setText("   " + mListAv.get(i).get(3));

        tv1.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Medium);
        tv2.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Medium);
        tv3.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Medium);
        //tv4.setTextAppearance(mActivity,android.R.style.TextAppearance_DeviceDefault_Medium);

        tv1.setPadding(5, 5, 5, 5);
        tv2.setPadding(5, 5, 5, 5);
        tv3.setPadding(5, 5, 5, 5);
        //tv4.setPadding(5,5,5,5);

        /*tv2.setBackgroundResource(R.drawable.card_divider);
        tv3.setBackgroundResource(R.drawable.card_divider);
        tv4.setBackgroundResource(R.drawable.card_divider);*/

        row.addView(tv1);
        row.addView(tv2);
        row.addView(tv3);
        //row.addView(tv4);

        row.setBackgroundResource(R.drawable.button_selector);
        row.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
        row.setOnClickListener(this);
        mTblLayoutAv.addView(row);
    }
    LinearLayout ll = new LinearLayout(mActivity);
    ScrollView scrollView = new ScrollView(mActivity);
    TextView textViewTrnDtls = new TextView(mActivity);
    textViewTrnDtls.setText("Availability details:");
    textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large);
    textViewTrnDtls.setPadding(10, 10, 10, 10);
    ll.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    ll.setOrientation(LinearLayout.VERTICAL);
    ll.addView(textViewTrnDtls);
    ll.addView(mTblLayoutAv);
    scrollView.addView(ll);
    mFrameLayout.removeAllViews();
    mFrameLayout.addView(scrollView);
    if (mDialog.isShowing()) {
        mDialog.cancel();
    }
}

From source file:com.appfirst.activities.details.AFServerDetail.java

/**
 * Draw a ScrollView to display the Disk usage for each disk.
 * /*from  w  ww. ja v  a  2 s  .  c o  m*/
 * @return a ScrollView containing a list of AFBarView and AFPieView.
 */
private View createDiskListDialog() {
    // use the scroll view to scale
    ScrollView container = createOuterContainer();
    LinearLayout innerContainer = createInnerContainer();

    List<BasicNameValuePair> items = data.getDisk_percent_part();
    for (int i = 0; i < items.size(); i++) {
        BasicNameValuePair item = items.get(i);
        Double value = Double.parseDouble(item.getValue());
        String name = item.getName();
        LinearLayout row = createTableRow(LinearLayout.HORIZONTAL);
        AFPieView pieView = createPieView(value);
        row.addView(pieView);
        TextView text = new TextView(this);
        text.setPadding(10, 0, 0, 0);
        text.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
        text.setText(String.format("%s - %.1f %s used", name, value, "%"));

        row.addView(text);
        innerContainer.addView(row);
    }
    container.addView(innerContainer);
    innerContainer.invalidate();
    container.invalidate();
    return container;
}

From source file:com.appfirst.activities.details.AFServerDetail.java

/**
 * Draw a ScrollView to display the Disk busy for each disk.
 * //ww w . j  a  v a2 s  .com
 * @return a ScrollView containing a list of AFBarView and AFPieView.
 */
private View createDiskBusyListDialog() {
    ScrollView container = createOuterContainer();

    LinearLayout innerContainer = createInnerContainer();

    List<BasicNameValuePair> items = data.getDisk_busy();
    for (int i = 0; i < items.size(); i++) {
        BasicNameValuePair item = items.get(i);
        Double value = 0.0;
        try {
            value = Double.parseDouble(item.getValue());
        } catch (Exception e) {
            e.printStackTrace();
            continue;
        }
        String name = item.getName();
        LinearLayout row = createTableRow(LinearLayout.VERTICAL);
        TextView text = new TextView(this);
        text.setPadding(5, 0, 0, 0);
        text.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
        text.setText(name);
        AFBarView barView = createBarView(value);

        row.addView(barView);
        row.addView(text);
        innerContainer.addView(row);
    }
    container.addView(innerContainer);
    innerContainer.invalidate();
    container.invalidate();
    return container;
}

From source file:ru.for_inform.we_recommend.view.Loading_Activity.java

private void showLicenseDialog() {

    // ? "  ?  ??"
    licenseDialog = new Dialog(context, R.style.InfoDialog_Theme);
    licenseDialog.setContentView(R.layout.license_dialog_layout);
    licenseDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));

    //      "? ??"
    notAgreeTV = (TextView) licenseDialog.findViewById(notAgreeTVResId);
    notAgreeTV.setOnClickListener(Loading_Activity.this);

    //      "?"/*from ww w.j a  v  a  2  s  .com*/
    agreeTV = (TextView) licenseDialog.findViewById(agreeTVResId);
    agreeTV.setOnClickListener(Loading_Activity.this);

    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    //  "? ? "
    final ScrollView scrollViewSV = (ScrollView) licenseDialog.findViewById(R.id.LicenseDialog_ScrollViewSV);

    // ? ? ?  ??
    TextView licenseTextTV = new TextView(context);
    licenseTextTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));
    licenseTextTV.setTextSize(8);
    licenseTextTV.setTextColor(context.getResources().getColor(R.color.black));
    licenseTextTV.setText(getAssetData(R.string.license_path));
    setPaddings(licenseTextTV, 10, 0, 10, 0);

    // ? ? ?  
    scrollViewSV.addView(licenseTextTV);

    //  ?  
    licenseDialog.show();
}

From source file:org.openremote.android.console.AppSettingsActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setTitle(R.string.settings);/*from  w ww . j a  va2s . com*/

    this.autoMode = AppSettingsModel.isAutoMode(AppSettingsActivity.this);

    // The main layout contains all application configuration items.
    LinearLayout mainLayout = new LinearLayout(this);
    mainLayout
            .setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    mainLayout.setOrientation(LinearLayout.VERTICAL);
    mainLayout.setBackgroundColor(0);
    mainLayout.setTag(R.string.settings);

    loadingPanelProgress = new ProgressDialog(this);

    // The scroll view contains appSettingsView, and make the appSettingsView can be scrolled.
    ScrollView scroll = new ScrollView(this);
    scroll.setVerticalScrollBarEnabled(true);
    scroll.setLayoutParams(
            new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 1));
    appSettingsView = new LinearLayout(this);
    appSettingsView
            .setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    appSettingsView.setOrientation(LinearLayout.VERTICAL);

    appSettingsView.addView(createAutoLayout());
    appSettingsView.addView(createChooseControllerLabel());

    currentServer = "";
    if (autoMode) {
        appSettingsView.addView(constructAutoServersView());
    } else {
        appSettingsView.addView(constructCustomServersView());
    }
    appSettingsView.addView(createChoosePanelLabel());
    panelSelectSpinnerView = new PanelSelectSpinnerView(this);
    appSettingsView.addView(panelSelectSpinnerView);

    appSettingsView.addView(createCacheText());
    appSettingsView.addView(createClearImageCacheButton());
    appSettingsView.addView(createSSLLayout());
    scroll.addView(appSettingsView);

    mainLayout.addView(scroll);
    mainLayout.addView(createDoneAndCancelLayout());

    setContentView(mainLayout);
    initSSLState();
    addOnclickListenerOnDoneButton();
    addOnclickListenerOnCancelButton();
    progressLayout = (LinearLayout) findViewById(R.id.choose_controller_progress);

}

From source file:com.mplayer_remote.ServerList.java

/**
 * Metoda wywoywana przez system Android przy starcie aktywnoci.
 * Tu nastpuje wyczytanie ustawie aplikacji, zainicjowanie GUI aktywnoci, wywietlenie jednego z okien dialogowych dialog_FIRST_TIME_RUNING lub dialog_GIVE_ME_A_APP_PASSWORD 
 * albo odszyfrowanie pliku z zapisan list serwerw (w przypadku gdy metoda onCreate wywoywana jest po restarcie aktywnoci lub gdy aplikacja szyfruje dane domylnym hasem). 
 * @see android.app.Activity#onCreate(android.os.Bundle)
 *///from w ww  . j a v a  2s  .c om
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //ustawianie GUI
    ScrollView sv = new ScrollView(this);
    ll = new LinearLayout(this);
    ll.setOrientation(LinearLayout.VERTICAL);
    TextView text = new TextView(this);
    text.setText(R.string.activity_server_list_title);
    text.setTextSize(18);
    ll.addView(text);
    sv.addView(ll);
    this.setContentView(sv);

    //creating a XML
    Context mContext = getApplicationContext();
    aXMLReaderWriter = new XMLReaderWriter(mContext);

    settingsForAPPSharedPreferences = getSharedPreferences("settings_for_APP", 0);
    isThisFirstRunboolean = settingsForAPPSharedPreferences.getBoolean("is_this_first_run", true);
    isCryptoEnabledboolean = settingsForAPPSharedPreferences.getBoolean("is_crypto_enabled", true); //byo false
    rememberAppPasswordInSesionboolean = settingsForAPPSharedPreferences
            .getBoolean("remember_app_password_in_sesion_boolean", true);

    Log.v(TAG, "aktualny isThisFirstRunboolean: " + isThisFirstRunboolean);
    Log.v(TAG, "aktualny isCryptoEnabledboolean: " + isCryptoEnabledboolean);
    Log.v(TAG, "aktualny rememberAppPasswordInSesionboolean: " + rememberAppPasswordInSesionboolean);
    /*
    Intent intent_from_SettingsForServerList = getIntent(); //getIntent() zwraca obiekt Intent ktry wystartowa Activity
    appPasswordcharArray = intent_from_SettingsForServerList.getCharArrayExtra("app_password");
    */
    if (appPasswordcharArray != null) {
        String appPasswordcharArrayConvertedToString = new String(appPasswordcharArray);
        Log.v(TAG, "Aktuane appPasswordcharArray: " + appPasswordcharArrayConvertedToString);
    }

    if (savedInstanceState != null) {
        serverToEditint = savedInstanceState.getInt("serverToEditint");
        serverToDelete = savedInstanceState.getInt("serverToDelete");
    }
    Object retained = getLastNonConfigurationInstance();
    if (retained != null && retained instanceof StateHolder) { //if onCreate follow configuration change
        mStateHolder = (StateHolder) retained;
    } else {
        mStateHolder = new StateHolder(); //a normal activity start
    }

    //if (rememberAppPasswordInSesionboolean == false){
    //Intent intent_from_SettingsForServerList = getIntent(); //getIntent() zwraca obiekt Intent ktry wystartowa Activity
    //appPasswordcharArray = intent_from_SettingsForServerList.getCharArrayExtra("app_password");
    //}

    if (isThisFirstRunboolean == true && mStateHolder.mIsShowingDialog_FIRST_TIME_RUNING == false) { //if configuration change happens them onResume will show dialog
        Log.v(TAG,
                "(isThisFirstRunboolean == true && mStateHolder.mIsShowingDialog_FIRST_TIME_RUNING == false) ");
        showdialog_FIRST_TIME_RUNING();

    } else if (isCryptoEnabledboolean == true && appPasswordcharArray == null
            && mStateHolder.mIsShowingDialog_GIVE_ME_A_PASSWORD == false && isThisFirstRunboolean == false) {
        //I check isThisFirstRunboolean == false because screen rotation can trigger this on real first app run
        Log.v(TAG,
                "(isCryptoEnabledboolean == true && appPasswordcharArray == null && mStateHolder.mIsShowingDialog_GIVE_ME_A_PASSWORD == false && isThisFirstRunboolean == false)");
        showdialog_GIVE_ME_A_APP_PASSWORD();

    } else if (isCryptoEnabledboolean == true && appPasswordcharArray != null
            && mStateHolder.mIsShowingDialog_FIRST_TIME_RUNING == false) { // I check && mStateHolder.mIsShowingDialog_FIRST_TIME_RUNING == false because screen rotation can trigger this when back form SettingsForAPP
        Log.v(TAG,
                "(isCryptoEnabledboolean == true && appPasswordcharArray != null && mStateHolder.mIsShowingDialog_FIRST_TIME_RUNING == false)");
        try {
            serverListArrayList = aXMLReaderWriter
                    .decryptFileWithXMLAndParseItToServerList(appPasswordcharArray);

            if (serverListArrayList != null) {
                for (int i = 0; i < serverListArrayList.size(); i++) {

                    createConnectButtons(i);

                }
            }
        } catch (WrongPasswordException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    } else if (isCryptoEnabledboolean == false) { //isThisFirstRunboolean == false is checked because def values // usunem && isThisFirstRunboolean == false
        Log.v(TAG, "(isCryptoEnabledboolean == false )");
        appPasswordcharArray = "default_password".toCharArray();
        try {
            serverListArrayList = aXMLReaderWriter
                    .decryptFileWithXMLAndParseItToServerList(appPasswordcharArray);

            if (serverListArrayList != null) {
                for (int i = 0; i < serverListArrayList.size(); i++) {

                    createConnectButtonsThatAskForServerPassword(i);

                }
            }

        } catch (WrongPasswordException e) {
            Toast.makeText(getApplicationContext(), R.string.wrong_app_password_exeption, Toast.LENGTH_SHORT)
                    .show();

        }

    }

}

From source file:com.juick.android.MainActivity.java

@TargetApi(VERSION_CODES.ICE_CREAM_SANDWICH)
private void selectSourcesForCombined(final String prefix, final String[] codes) {
    final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
    ScrollView v = new ScrollView(this);
    v.setLayoutParams(new ScrollView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    final LinearLayout ll = new LinearLayout(this);
    ll.setLayoutParams(new ScrollView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    ll.setOrientation(LinearLayout.VERTICAL);
    v.addView(ll);
    for (int i = 0; i < codes.length; i++) {
        final CompoundButton sw = VERSION.SDK_INT >= 14 ? new Switch(this) : new CheckBox(this);
        sw.setPadding(10, 10, 10, 10);/*from   ww w .  j av a  2 s  .co  m*/
        sw.setLayoutParams(new ScrollView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        sw.setText(codes[i]);
        sw.setChecked(sp.getBoolean(prefix + codes[i], true));
        ll.addView(sw);
    }

    new AlertDialog.Builder(MainActivity.this).setView(v).setCancelable(true)
            .setOnCancelListener(new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialogInterface) {
                    SharedPreferences.Editor e = sp.edit();
                    for (int i = 0; i < ll.getChildCount(); i++) {
                        CompoundButton cb = (CompoundButton) ll.getChildAt(i);
                        assert cb != null;
                        e.putBoolean(prefix + codes[i], cb.isChecked());
                    }
                    e.commit();
                }
            }).create().show();

}

From source file:com.blueoxfords.peacecorpstinder.activities.MainActivity.java

public void getLegalInfo(View v) {
    String photoId = v.getTag() + "";
    ImageRestClient.get().getInfoFromImageId(photoId, new Callback<ImageService.ImageInfoWrapper>() {
        @Override/*from w w  w  .  j  a  v  a  2s. co  m*/
        public void success(ImageService.ImageInfoWrapper imageInfoWrapper, Response response) {
            AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.activity);

            ScrollView wrapper = new ScrollView(MainActivity.activity);
            LinearLayout infoLayout = new LinearLayout(MainActivity.activity);
            infoLayout.setOrientation(LinearLayout.VERTICAL);
            infoLayout.setPadding(35, 35, 35, 35);

            TextView imageOwner = new TextView(MainActivity.activity);
            imageOwner.setText(Html.fromHtml("<b>Image By: </b>" + imageInfoWrapper.photo.owner.username));
            if (imageInfoWrapper.photo.owner.realname.length() > 0) {
                imageOwner.setText(imageOwner.getText() + " (" + imageInfoWrapper.photo.owner.realname + ")");
            }
            infoLayout.addView(imageOwner);

            if (getLicenseUrl(Integer.parseInt(imageInfoWrapper.photo.license)).length() > 0) {
                TextView licenseLink = new TextView(MainActivity.activity);
                licenseLink.setText(Html
                        .fromHtml("<a href=\"" + getLicenseUrl(Integer.parseInt(imageInfoWrapper.photo.license))
                                + "\"><b>Licensing</b></a>"));
                licenseLink.setMovementMethod(LinkMovementMethod.getInstance());
                infoLayout.addView(licenseLink);
            }

            if (imageInfoWrapper.photo.urls.url.size() > 0) {
                TextView imageLink = new TextView(MainActivity.activity);
                imageLink.setText(Html.fromHtml("<a href=\"" + imageInfoWrapper.photo.urls.url.get(0)._content
                        + "\"><b>Image Link</b></a>"));
                imageLink.setMovementMethod(LinkMovementMethod.getInstance());
                infoLayout.addView(imageLink);
            }

            if (imageInfoWrapper.photo.title._content.length() > 0) {
                TextView photoTitle = new TextView(MainActivity.activity);
                photoTitle
                        .setText(Html.fromHtml("<b>Image Title: </b>" + imageInfoWrapper.photo.title._content));
                infoLayout.addView(photoTitle);
            }

            if (imageInfoWrapper.photo.description._content.length() > 0) {
                TextView description = new TextView(MainActivity.activity);
                description.setText(Html
                        .fromHtml("<b>Image Description: </b>" + imageInfoWrapper.photo.description._content));
                infoLayout.addView(description);
            }

            TextView contact = new TextView(MainActivity.activity);
            contact.setText(
                    Html.fromHtml("<br><i>To remove this photo, please email pcorpsconnect@gmail.com</i>"));
            infoLayout.addView(contact);

            wrapper.addView(infoLayout);

            builder.setTitle("Photo Information");
            builder.setPositiveButton("Close", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {

                }
            });
            builder.setView(wrapper);
            builder.create().show();
        }

        @Override
        public void failure(RetrofitError error) {
            Log.i("testing", "could not retrieve legal/attribution info");
        }
    });
}

From source file:org.uguess.android.sysinfo.SiragonManager.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    final Activity ctx = getActivity();

    if (item.getItemId() == MI_PREFERENCE) {
        Intent it = new Intent(ctx, InfoSettings.class);

        it.putExtra(PREF_KEY_SHOW_INFO_ICON,
                Util.getBooleanOption(ctx, PSTORE_SYSINFOMANAGER, PREF_KEY_SHOW_INFO_ICON));
        it.putExtra(PREF_KEY_SHOW_TASK_ICON,
                Util.getBooleanOption(ctx, PSTORE_SYSINFOMANAGER, PREF_KEY_SHOW_TASK_ICON));
        it.putExtra(PREF_KEY_AUTO_START_ICON,
                Util.getBooleanOption(ctx, PSTORE_SYSINFOMANAGER, PREF_KEY_AUTO_START_ICON, false));
        it.putExtra(PREF_KEY_DEFAULT_SERVER,
                Util.getStringOption(ctx, PSTORE_SYSINFOMANAGER, PREF_KEY_DEFAULT_SERVER, null));
        it.putExtra(PREF_KEY_DEFAULT_EMAIL,
                Util.getStringOption(ctx, PSTORE_SYSINFOMANAGER, PREF_KEY_DEFAULT_EMAIL, null));
        it.putExtra(PREF_KEY_DEFAULT_TAB,
                Util.getIntOption(ctx, PSTORE_SYSINFOMANAGER, PREF_KEY_DEFAULT_TAB, 0));
        it.putExtra(PREF_KEY_WIDGET_DISABLED,
                Util.getStringOption(ctx, PSTORE_SYSINFOMANAGER, PREF_KEY_WIDGET_DISABLED, null));

        startActivityForResult(it, 2);/* w w w . j a v  a  2 s  .  c om*/

        return true;
    } else if (item.getItemId() == MI_HELP) {
        Intent it = new Intent(Intent.ACTION_VIEW);

        String target = "http://www.siragon.com.ve"; //$NON-NLS-1$

        ConnectivityManager cm = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);

        NetworkInfo info = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI);

        if (info != null && info.isConnected()) {
            target = "http://www.siragon.com.ve"; //$NON-NLS-1$
        }

        it.setData(Uri.parse(target));

        it = Intent.createChooser(it, null);

        startActivity(it);

        return true;
    }
    ///////////////////////PATH SERVER///////////////////////////////////

    else if (item.getItemId() == MI_ABOUT) {
        ScrollView sv = new ScrollView(ctx);

        TextView txt = new TextView(ctx);
        txt.setGravity(Gravity.CENTER_HORIZONTAL);
        txt.setTextAppearance(ctx, android.R.style.TextAppearance_Medium);

        sv.addView(txt);

        String href = "http://www.google.com.ve"; //$NON-NLS-1$

        txt.setText(Html.fromHtml(getString(R.string.about_msg,
                getVersionName(ctx.getPackageManager(), ctx.getPackageName()), href)));
        txt.setMovementMethod(LinkMovementMethod.getInstance());

        new AlertDialog.Builder(ctx).setTitle(R.string.app_name).setIcon(R.drawable.logo2).setView(sv)
                .setNegativeButton(R.string.close, null).create().show();

        return true;
    } else if (item.getItemId() == MI_EXIT) {
        OnClickListener listener = new OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {
                Util.killSelf(handler, ctx, (ActivityManager) ctx.getSystemService(Context.ACTIVITY_SERVICE),
                        ctx.getPackageName());
            }
        };

        new AlertDialog.Builder(ctx).setTitle(R.string.prompt).setMessage(R.string.exit_prompt)
                .setPositiveButton(android.R.string.yes, listener).setNegativeButton(android.R.string.no, null)
                .create().show();

        return true;
    } else if (item.getItemId() == MI_REFRESH) {
        updateInfo();
        return true;
    }

    return false;
}

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

private void showDynamicPricingPrompt() {
    final AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
    String message = "Apply Dynamic Pricing";
    String positiveButtonText = "Apply";
    final Utils.DPRequestType[] dpRequestType = new Utils.DPRequestType[1];
    ScrollView scrollView = new ScrollView(getActivity());
    LinearLayout linearLayout = (LinearLayout) getActivity().getLayoutInflater()
            .inflate(R.layout.dynamic_pricing_input_layout, null);
    final EditText editTransactionAmount = (EditText) linearLayout.findViewById(R.id.edit_txn_amount);
    final EditText editCouponCode = (EditText) linearLayout.findViewById(R.id.edit_coupon_code);
    final EditText editAlteredAmount = (EditText) linearLayout.findViewById(R.id.edit_altered_amount);
    final LinearLayout layoutCouponCode = (LinearLayout) linearLayout.findViewById(R.id.layout_for_coupon_code);
    final LinearLayout layoutAlteredAmount = (LinearLayout) linearLayout
            .findViewById(R.id.layout_for_altered_amount);
    Spinner spinner = (Spinner) linearLayout.findViewById(R.id.spinner_dp_request_type);
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override//  ww w . java  2 s  . co  m
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {

            switch (position) {
            case 0:
                dpRequestType[0] = Utils.DPRequestType.SEARCH_AND_APPLY;
                layoutCouponCode.setVisibility(View.GONE);
                layoutAlteredAmount.setVisibility(View.GONE);
                break;
            case 1:
                dpRequestType[0] = Utils.DPRequestType.CALCULATE_PRICING;
                layoutCouponCode.setVisibility(View.VISIBLE);
                layoutAlteredAmount.setVisibility(View.GONE);
                break;
            case 2:
                dpRequestType[0] = Utils.DPRequestType.VALIDATE_RULE;
                layoutCouponCode.setVisibility(View.VISIBLE);
                layoutAlteredAmount.setVisibility(View.VISIBLE);
                break;
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {

        }
    });

    alert.setTitle("Perform Dynamic Pricing");
    alert.setMessage(message);

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

        public void onClick(DialogInterface dialog, int whichButton) {
            String amount = editTransactionAmount.getText().toString();
            String alteredAmount = editAlteredAmount.getText().toString();
            String couponCode = editCouponCode.getText().toString();

            mListener.onPaymentTypeSelected(dpRequestType[0], new Amount(amount), couponCode,
                    new Amount(alteredAmount));

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

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

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