Example usage for android.widget ScrollView ScrollView

List of usage examples for android.widget ScrollView ScrollView

Introduction

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

Prototype

public ScrollView(Context context) 

Source Link

Usage

From source file:cc.metapro.openct.utils.ActivityUtils.java

public static AlertDialog addViewToAlertDialog(@NonNull final AlertDialog.Builder builder,
        @NonNull final View view) {
    ViewGroup parent = (ViewGroup) view.getParent();
    if (parent != null) {
        parent.removeView(view);/* w ww  . java 2s. c  o  m*/
    }

    ScrollView scrollView = new ScrollView(builder.getContext());
    scrollView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    scrollView.addView(view);

    builder.setOnDismissListener(new DialogInterface.OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialog) {
            InputMethodManager imm = (InputMethodManager) builder.getContext()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
        }
    });

    AlertDialog dialog = builder.setView(scrollView).create();
    Window window = dialog.getWindow();
    if (window != null) {
        window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    }
    return dialog;
}

From source file:org.dalmasso.ietfsched.ui.WellNoteFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ScrollView scroller = new ScrollView(getActivity());
    TextView text = new TextView(getActivity());
    text.setText(WELL_NOTE_TEXT);/*from w ww.  j  av a2s  .  c om*/
    scroller.addView(text);
    return scroller;
}

From source file:edu.htl3r.schoolplanner.gui.timetable.WeekViewPageAdapter.java

@Override
public synchronized View instantiateItem(View collection, int position) {

    int di = position - 50;

    DateTime ad = new DateTime();
    ad.set(date.getDay() + (di * 7), date.getMonth(), date.getYear());

    InputTransferObject input = new InputTransferObject(ad, position);

    if (!view_cach[position].isDataHere()) {
        downloadschlange.add(input);/* w  w w  .j a  v  a 2  s .co  m*/
    }

    ViewPager tmp = (ViewPager) collection;

    tmp.removeView((ScrollView) view_cach[position].getParent());

    oldpos = position;

    ScrollView scr = new ScrollView(context);
    scr.addView(view_cach[position]);
    tmp.addView(scr);

    return scr;

}

From source file:com.normalexception.app.rx8club.fragment.utils.CompressionFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    MainApplication.setState(AppState.State.UTIL_COMPRESSION, this);

    RelativeLayout rl = (RelativeLayout) getView().findViewById(R.id.content_frame);

    v = getActivity().getLayoutInflater().inflate(R.layout.view_compression, rl);

    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);/*from  w  w w .  j a  v  a2s .  co  m*/
    params.addRule(RelativeLayout.BELOW, R.id.mainlisttitle);

    ScrollView sv = new ScrollView(getActivity());
    sv.addView(v);
    sv.setLayoutParams(params);

    rl.addView(sv);

    ViewHolder.get(v, R.id.compressionNormalize).setOnClickListener(new CompressionListener());
}

From source file:de.gebatzens.ggvertretungsplan.fragment.ExamFragment.java

@Override
public void createView(LayoutInflater inflater, ViewGroup view) {
    ScrollView sv = new ScrollView(getActivity());
    sv.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    sv.setTag("exam_scroll");
    ((LinearLayout) view.findViewById(R.id.exam_content)).addView(sv);
    LinearLayout l = new LinearLayout(getActivity());
    l.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    l.setOrientation(LinearLayout.VERTICAL);
    int p = toPixels(6);
    l.setPadding(p, p, p, p);/*from www.  j ava 2 s.  co  m*/
    sv.addView(l);
    createTextView(getResources().getString(R.string.my_exams), toPixels(12), inflater, l);
    for (Exams.ExamItem item : GGApp.GG_APP.exams) {
        if (GGApp.GG_APP.filters.mainFilter.matches(item)) {
            CardView cv = createCardItem(item, inflater);
            if (cv != null) {
                l.addView(cv);
            }
        }

    }
    createTextView(getResources().getString(R.string.all_exams), toPixels(12), inflater, l);
    for (Exams.ExamItem item : GGApp.GG_APP.exams) {
        CardView cv = createCardItem(item, inflater);
        if (cv != null) {
            l.addView(cv);
        }
    }
    cardColorIndex = 0;
}

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  v  a 2  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:eu.geopaparazzi.core.maptools.FeaturePageAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    final Feature feature = featuresList.get(position);

    int bgColor = Compat.getColor(context, eu.geopaparazzi.library.R.color.formbgcolor);
    int textColor = Compat.getColor(context, eu.geopaparazzi.library.R.color.formcolor);

    ScrollView scrollView = new ScrollView(context);
    ScrollView.LayoutParams scrollLayoutParams = new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);//from w w w  . j a v a 2 s  .co m
    scrollLayoutParams.setMargins(10, 10, 10, 10);
    scrollView.setLayoutParams(scrollLayoutParams);
    scrollView.setBackgroundColor(bgColor);

    LinearLayout linearLayoutView = new LinearLayout(context);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    int margin = 10;
    layoutParams.setMargins(margin, margin, margin, margin);
    linearLayoutView.setLayoutParams(layoutParams);
    linearLayoutView.setOrientation(LinearLayout.VERTICAL);
    int padding = 10;
    linearLayoutView.setPadding(padding, padding, padding, padding);
    scrollView.addView(linearLayoutView);

    List<String> attributeNames = feature.getAttributeNames();
    List<String> attributeValues = feature.getAttributeValuesStrings();
    List<String> attributeTypes = feature.getAttributeTypes();
    for (int i = 0; i < attributeNames.size(); i++) {
        final String name = attributeNames.get(i);
        String value = attributeValues.get(i);
        String typeString = attributeTypes.get(i);
        EDataType type = EDataType.getType4Name(typeString);

        TextView textView = new TextView(context);
        textView.setLayoutParams(
                new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
        textView.setPadding(padding, padding, padding, padding);
        textView.setText(name);
        textView.setTextColor(textColor);
        // textView.setTextAppearance(context, android.R.style.TextAppearance_Medium);

        linearLayoutView.addView(textView);

        final TextView editView = getEditView(feature, name, type, value);
        LinearLayout.LayoutParams editViewParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                LayoutParams.WRAP_CONTENT);
        editViewParams.setMargins(margin, 0, margin, 0);
        editView.setLayoutParams(editViewParams);
        editView.setPadding(padding * 2, padding, padding * 2, padding);
        editView.setFocusable(!isReadOnly);

        if (isReadOnly) {
            editView.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    String text = editView.getText().toString();
                    FeatureUtilities.viewIfApplicable(v.getContext(), text);
                    return false;
                }
            });
        }
        linearLayoutView.addView(editView);
    }

    /*
     * add also area and length
     */
    if (feature.getOriginalArea() > -1) {
        TextView areaTextView = new TextView(context);
        areaTextView.setLayoutParams(
                new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
        areaTextView.setPadding(padding, padding, padding, padding);
        areaTextView.setText(context.getString(eu.geopaparazzi.core.R.string.area_colon)
                + areaLengthFormatter.format(feature.getOriginalArea()));
        areaTextView.setTextColor(textColor);
        TextView lengthTextView = new TextView(context);
        lengthTextView.setLayoutParams(
                new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
        lengthTextView.setPadding(padding, padding, padding, padding);
        lengthTextView.setText(context.getString(eu.geopaparazzi.core.R.string.length_colon)
                + areaLengthFormatter.format(feature.getOriginalLength()));
        lengthTextView.setTextColor(textColor);
        linearLayoutView.addView(areaTextView);
        linearLayoutView.addView(lengthTextView);
    }
    container.addView(scrollView);

    return scrollView;
}

From source file:com.ryan.ryanreader.activities.CommentEditActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    PrefsUtility.applyTheme(this);

    super.onCreate(savedInstanceState);

    final LinearLayout layout = (LinearLayout) getLayoutInflater().inflate(R.layout.comment_edit);

    textEdit = (EditText) layout.findViewById(R.id.comment_reply_text);

    if (getIntent() != null && getIntent().hasExtra("commentIdAndType")) {
        commentIdAndType = getIntent().getStringExtra("commentIdAndType");
        textEdit.setText(getIntent().getStringExtra("commentText"));

    } else if (savedInstanceState != null && savedInstanceState.containsKey("commentIdAndType")) {
        textEdit.setText(savedInstanceState.getString("commentText"));
        commentIdAndType = savedInstanceState.getString("commentIdAndType");
    }/*from  ww w  .j  a v  a2s.  c  o  m*/

    final ScrollView sv = new ScrollView(this);
    sv.addView(layout);
    setContentView(sv);
}

From source file:de.gebatzens.sia.fragment.RemoteDataFragment.java

public View createLoadingView() {
    ScrollView sv = new ScrollView(getActivity());
    sv.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    sv.setTag("gg_scroll");
    sv.setFillViewport(true);/*from  www  .  j av  a  2  s  .  co  m*/
    LinearLayout l = new LinearLayout(getActivity());
    l.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    l.setGravity(Gravity.CENTER);

    ProgressBar pb = new ProgressBar(getActivity());
    pb.getIndeterminateDrawable().setColorFilter(SIAApp.SIA_APP.school.getAccentColor(),
            PorterDuff.Mode.SRC_IN);
    pb.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    pb.setVisibility(ProgressBar.VISIBLE);

    l.addView(pb);
    sv.addView(l);
    return sv;
}

From source file:com.ryan.ryanreader.activities.CommentReplyActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    PrefsUtility.applyTheme(this);

    super.onCreate(savedInstanceState);

    final LinearLayout layout = (LinearLayout) getLayoutInflater().inflate(R.layout.comment_reply);

    usernameSpinner = (Spinner) layout.findViewById(R.id.comment_reply_username);
    textEdit = (EditText) layout.findViewById(R.id.comment_reply_text);

    if (getIntent() != null && getIntent().hasExtra("parentIdAndType")) {
        parentIdAndType = getIntent().getStringExtra("parentIdAndType");

    } else if (savedInstanceState != null && savedInstanceState.containsKey("comment_text")) {
        textEdit.setText(savedInstanceState.getString("comment_text"));
        parentIdAndType = savedInstanceState.getString("parentIdAndType");

    } else if (lastText != null) {
        textEdit.setText(lastText);/*from   w  w w.  ja v  a  2 s.c  o m*/
        parentIdAndType = lastParentIdAndType;
    }

    final ArrayList<RedditAccount> accounts = RedditAccountManager.getInstance(this).getAccounts();
    final ArrayList<String> usernames = new ArrayList<String>();

    for (RedditAccount account : accounts) {
        if (!account.isAnonymous()) {
            usernames.add(account.username);
        }
    }

    if (usernames.size() == 0) {
        General.quickToast(this, "You must be logged in to do that.");
        finish();
    }

    usernameSpinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, usernames));

    final ScrollView sv = new ScrollView(this);
    sv.addView(layout);
    setContentView(sv);
}