Created
February 3, 2018 10:43
-
-
Save rajajawahar/d6c4b9d47ac54ba0ab38576d1fc035d6 to your computer and use it in GitHub Desktop.
Change the textview attributes programatically while clicking
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TextView textView = new TextView(this); | |
textView.setText("Test"); | |
textView.setId("Your Id"); | |
textView.setOnClickListener(new View.OnClickListener() { | |
@Override public void onClick(View view) { | |
changeTextViewAttributes() | |
} | |
}); | |
RelativeLayout.LayoutParams layoutParams = | |
new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, | |
ViewGroup.LayoutParams.WRAP_CONTENT); | |
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); | |
textView.setLayoutParams(layoutParams); | |
relativeLayout.addView(textView); | |
public void changeTextViewAttributes(View view) { | |
TextView tv = (TextView) view; | |
switch (view.getId()) { | |
case 0: | |
//change the attributes | |
break; | |
case 1: | |
break; | |
case 2: | |
break; | |
case 3: | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment