Example usage for android.widget ScrollView postDelayed

List of usage examples for android.widget ScrollView postDelayed

Introduction

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

Prototype

public boolean postDelayed(Runnable action, long delayMillis) 

Source Link

Document

Causes the Runnable to be added to the message queue, to be run after the specified amount of time elapses.

Usage

From source file:eu.fistar.sdcs.pa.MainActivity.java

private void updateLog(String log) {
    Log.d(LOGTAG, log);/*from w ww  .ja  v  a 2  s.  c  o m*/

    final String fLog = log;

    final TextView tv = (TextView) findViewById(R.id.logBox);
    tv.post(new Runnable() {
        @Override
        public void run() {
            tv.append(fLog + "\n");
        }
    });

    final ScrollView sv = (ScrollView) findViewById(R.id.scrollBox);
    sv.postDelayed(new Runnable() {
        @Override
        public void run() {
            sv.fullScroll(ScrollView.FOCUS_DOWN);
        }
    }, 100L);

}

From source file:cx.ring.fragments.AccountCreationFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
    final View inflatedView = inflater.inflate(R.layout.frag_account_creation, parent, false);

    mAliasView = (EditText) inflatedView.findViewById(R.id.alias);
    mHostnameView = (EditText) inflatedView.findViewById(R.id.hostname);
    mUsernameView = (EditText) inflatedView.findViewById(R.id.username);
    mPasswordView = (EditText) inflatedView.findViewById(R.id.password);

    mPasswordView.setOnEditorActionListener(new OnEditorActionListener() {
        @Override//  ww  w .  ja v  a2s  . c  o  m
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == getResources().getInteger(R.integer.register_sip_account_actionid) || event == null
                    || (event.getAction() == KeyEvent.ACTION_UP)) {
                inflatedView.findViewById(R.id.create_sip_button).callOnClick();
            }
            return true;
        }
    });
    inflatedView.findViewById(R.id.ring_card_view).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mAccountType = AccountDetailBasic.ACCOUNT_TYPE_RING;
            initAccountCreation();
        }
    });
    inflatedView.findViewById(R.id.create_sip_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mAccountType = AccountDetailBasic.ACCOUNT_TYPE_SIP;
            mAlias = mAliasView.getText().toString();
            mHostname = mHostnameView.getText().toString();
            mUsername = mUsernameView.getText().toString();
            mPassword = mPasswordView.getText().toString();
            attemptCreation();
        }
    });
    inflatedView.findViewById(R.id.import_card_view).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            startImport();
        }
    });

    mSipFormLinearLayout = (LinearLayout) inflatedView.findViewById(R.id.sipFormLinearLayout);
    mSipFormLinearLayout.setVisibility(View.GONE);
    inflatedView.findViewById(R.id.sipHeaderLinearLayout).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (null != mSipFormLinearLayout) {
                if (mSipFormLinearLayout.getVisibility() != View.VISIBLE) {
                    mSipFormLinearLayout.setVisibility(View.VISIBLE);
                    //~ Let the time to perform setVisibility before scrolling.
                    final ScrollView loginForm = (ScrollView) inflatedView.findViewById(R.id.login_form);
                    loginForm.postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            loginForm.fullScroll(ScrollView.FOCUS_DOWN);
                            mAliasView.requestFocus();
                        }
                    }, 100);
                }
            }
        }
    });

    return inflatedView;
}