Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>public class SecondActivity extends Activity{ @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); // Log tag; // Log.d("testing", "In toggle java"); setContentView(R.layout.togglebtn); **Changes here** **EditText etPass = (EditText) findViewById(R.id.etPassword); Button btPass =(Button) findViewById(R.id.btPassword); ToggleButton tgPass = (ToggleButton) findViewById(R.id.tgPassword); TextView tvPass = (TextView) findViewById(R.id.displayTV); Random animate = new Random();** passTextCheck(); textPosition(); } public void passTextCheck(){ tgPass.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub if(tgPass.isChecked()){ etPass.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); }else{ etPass.setInputType(InputType.TYPE_CLASS_TEXT); } } }); } public void textPosition(){ btPass.setOnClickListener(new View.OnClickListener() { // Toast testToast = new Toast(toggle.this); CharSequence text; @Override public void onClick(View v) { String check = tgPass.getText().toString(); if(check.contentEquals("left")){ tvPass.setGravity(Gravity.LEFT); tvPass.setTextColor(Color.BLUE); text = "Left + Blue"; Toast.makeText(SecondActivity.this, text ,Toast.LENGTH_SHORT).show(); }else if(check.contentEquals("right")){ tvPass.setGravity(Gravity.RIGHT); tvPass.setTextColor(Color.GREEN); text = "Right + Green"; Toast.makeText(SecondActivity.this, text ,Toast.LENGTH_SHORT).show(); }else if(check.contentEquals("center")){ tvPass.setGravity(Gravity.CENTER); tvPass.setTextColor(Color.MAGENTA); text = "Center + Magenta"; Toast.makeText(SecondActivity.this, text ,Toast.LENGTH_SHORT).show(); }else if(check.contentEquals("animate")){ tvPass.setText("Hello"); tvPass.setGravity(Gravity.CENTER); tvPass.setTextColor(Color.rgb(animate.nextInt(50), animate.nextInt(50),animate.nextInt(50)) ); } // TODO Auto-generated method stub } }); } </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload