is there anyway to change which view you are editing based upon the value of a int?
Without using a if statement?
for example:
int counter = 1;
public void attach(){
final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
TextView text1 = (TextView) findViewById(R.id.text1)
TextView text2 = (TextView) findViewById(R.id.text2)
TextView text3 = (TextView) findViewById(R.id.text3)
TextView text4 = (TextView) findViewById(R.id.text4)
if (counter < 5){
if (sp.getInt("test" + counter , 0) == counter){
text + counter .setText("test" + counter);
}else{counter = counter + 1; attach();}}
}
Simplest way is to define an array of possible view IDs.
int[] viewIds = new int[] {
R.id.text1,
R.id.text2,
R.id.text3,
R.id.text4
}
//some code
int i = /*whatever*/;
TextView tv = (TextView)findViewById(viewIds[i]);
tv.setText("test"+i);
Related
This is for searching the word on the TextView
public void viewWord(View view)
{
score = (TextView)findViewById(R.id.yourScore);
tv2 = (TextView)findViewById(R.id.tv2);
tv3 = (TextView)findViewById(R.id.tv3);
searchWord = (ImageView) findViewById(R.id.searchWord);
wordList = (ListView) findViewById(R.id.wordList);
text = (AutoCompleteTextView) findViewById(R.id.textHere);
wordList = (ListView) findViewById(R.id.wordList);
//SearchWord in AutoCompleteTextView text
//Display equivalent score of word in TextView score
String s1= search.getText().toString();
String s2= dbHelper.getData(s1);
score.setText(s2);
tv2.setText(s2);
tv3.setText(s2);
//Get data from textview
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, new ArrayList<String>());
wordList.setAdapter(adapter);
adapter.add(text.getText().toString());
adapter.notifyDataSetChanged();
text.setText("");
add();
}
public void add (){
x = Integer.parseInt(tv2.getText().toString());
y = Integer.parseInt(tv3.getText().toString());
z = x + y;
score.setText(Double.toString(z));
}
In my app, I am using an ImageView to search the word and display the score. I am having a hard time in displaying the score using 1 TextView so I decided to make it 2. I want my ImageView to function like this:
if(onMyImageViewFirstClick){
display the score on textview1
}
else{
if(onMyImageViewSecondClick){
display the score on textview2
}
how can i do it this way? Any suggestions will be highly appreciated :)
Note: I am new in android programming. I would appreciate if you'll also help me with the codes
You can do it with a class variable changin his value between 0 - 1, for example:
private int optionTxtView = 0
imageButton = (ImageButton) findViewById(R.id.imageButton1);
imageButton.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
if(optionTxtView == 0){
//display the score on textview1
optionTxtView = 1;
}else{
//display the score on textview2
optionTxtView = 0;
}
}
});
or you can use a boolean value (suggested by #mapo)
private boolean optionTxtView;
imageButton = (ImageButton) findViewById(R.id.imageButton1);
imageButton.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
if(optionTxtView){
//display the score on textview1
optionTxtView = false;
}else{
//display the score on textview2
optionTxtView = true;
}
}
});
So, according to your code, the solution must be:
//declare a boolean variable
private int optionTxtView = 0
public void viewWord(View view) {
...
...
...
//SearchWord in AutoCompleteTextView text
//Display equivalent score of word in TextView score
String s1= search.getText().toString();
String s2= dbHelper.getData(s1);
score.setText(s2);
if(optionTxtView == 0){
//display the score on textview1
tv2.setText(s2);
optionTxtView = 1;
}else{
//display the score on textview2
tv3.setText(s2);
optionTxtView = 0;
}
...
...
...
}
Here's how you can implement a click counter.
Note how you reset the counter when a total of 2 clicks are registered. Once that happens the counter starts over and again will first affect tv1 and then tv2.
// Find TextViews before (so you don't have to repeat this expensive operation)
final TextView tv1 = findViewById(R.id.textView1);
final TextView tv2 = findViewById(R.id.textView2);
imageButton.setOnClickListener(new View.OnClickListener() {
int numberOfClicks = 0;
#Override
public void onClick(View view) {
++numberOfClicks;
if(numberOfClicks < 2){
tv1.setText("Some text");
} else if(numberOfClicks >= 2){
tv1.setText("Some other text");
// Reset the click counter
numberOfClicks = 0;
}
}
});
Here's my codes
//declare a boolean variable for score
private int optionTxtView = 0 ;
//Search word
//display score
public void viewWord(View view)
{
score = (TextView)findViewById(R.id.yourScore);
tv2 = (TextView)findViewById(R.id.tv2);
tv3 = (TextView)findViewById(R.id.tv3);
searchWord = (ImageView) findViewById(R.id.searchWord);
wordList = (ListView) findViewById(R.id.wordList);
text = (AutoCompleteTextView) findViewById(R.id.textHere);
wordList = (ListView) findViewById(R.id.wordList);
String s1= search.getText().toString();
String s2= dbHelper.getData(s1);
if(optionTxtView == 0){
//display the score on textview1
tv2.setText(s2);
optionTxtView = 1;
}
else{
//display the score on textview2
tv3.setText(s2);
optionTxtView = 0;
}
calculate();
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, new ArrayList<String>());
wordList.setAdapter(adapter);
adapter.add(text.getText().toString());
adapter.notifyDataSetChanged();
text.setText(null);
}
private void calculate(){
x = Integer.parseInt(tv2.getText().toString());
y = Integer.parseInt(tv3.getText().toString());
z = x + y;
score.setText(Integer.toString(z));
}
So basically i decided to have 3 textviews, score, tv2 and tv3. So the first score for the first word should be in the tv2 and the second score should be in tv3. and the sum of this two textviews should be in score.
After putting text on the textview, it will search for the word from the textview in the database by hitting imagebutton. If the word is in the database, it will automatically put the word in the listview and at the same time it SHOULD display the score on two textviews.
I really need help on this. I tried everything i can but it never adds EXCEPT when the value/number in the textview tv2 and tv3 is set from the properties. But whenever the numbers/value is from the database (because that's what it should be) it NEVER ADDS !
Any help will be highly appreciated. Please help me with my codes.
onCreate Method
//TAKE NOTE: 16 IMAGEBUTTONS
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
dbHelper =new DBAdapter(this);
search = (EditText) findViewById(R.id.textHere);
words = (EditText) findViewById(R.id.edWord);
scores = (EditText) findViewById(R.id.edScore);
show_addWord = (ImageView) findViewById(R.id.show_addWord);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, new ArrayList<String>());
wordList.setAdapter(adapter);
score = (TextView)findViewById(R.id.yourScore);
tv2 = (TextView)findViewById(R.id.tv2);
tv3 = (TextView)findViewById(R.id.tv3);
wordList = (ListView) findViewById(R.id.wordList);
text = (AutoCompleteTextView) findViewById(R.id.textHere);
wordList = (ListView) findViewById(R.id.wordList);
blizzard = (ImageView) findViewById(R.id.blizzard);
bomb = (ImageView) findViewById(R.id.bomb);
searchWord = (ImageView) findViewById(R.id.searchWord);
wordList = (ListView) findViewById(R.id.wordList); //this is til 16
image1 = (ImageButton) findViewById(R.id.Button1);
image16 = (ImageButton) findViewById(R.id.Button16);
timer = (TextView) this.findViewById(R.id.timer);
timer.setText("00:00:30");
countDownTimer = new MyCountDownTimer(30000,1000);
final AutoCompleteTextView text = (AutoCompleteTextView) findViewById(R.id.textHere);
final ImageButton image1 = (ImageButton) findViewById(R.id.Button1); //this is til 16
final ImageButton image16 = (ImageButton) findViewById(R.id.Button16);
final int[] myPics = { R.drawable.a, R.drawable.b, R.drawable.c,
R.drawable.e }; //this is til z
//this is til 16
int rando = (int)(Math.random()* 5);
image1.setImageResource(myPics[rando]);
image1.setId(myPics[rando]);
//this is from a -z
OnClickListener myCommoClickListner = new OnClickListener(){
#Override
public void onClick(View arg0) {
Log.i(TAG,"arg0.getId() = " + arg0.getId());
if(arg0.getId()==R.drawable.a){
Log.i(TAG,"arg0.getId()="+arg0.getId());
generatedString=generatedString+"a"; //[PLACEE RESPACTIVE CHARACTEER HERE]
text.setText(generatedString);
((ImageButton) arg0).setImageResource(R.drawable.changea);
if (!timeHasStarted) {
countDownTimer.start();
timeHasStarted = true;
}
else{
if(arg0.getId()==R.drawable.z){
Log.i(TAG,"arg0.getId() = " + arg0.getId());
generatedString = generatedString+"z";
text.setText(generatedString);
((ImageButton) arg0).setImageResource(R.drawable.changez);
if (!timeHasStarted) {
countDownTimer.start();
timeHasStarted = true;
}
}
}
};
image1.setOnClickListener(myCommoClickListner);
image2.setOnClickListener(myCommoClickListner);
image3.setOnClickListener(myCommoClickListner);
image4.setOnClickListener(myCommoClickListner);
image5.setOnClickListener(myCommoClickListner);
image6.setOnClickListener(myCommoClickListner);
image7.setOnClickListener(myCommoClickListner);
image8.setOnClickListener(myCommoClickListner);
image9.setOnClickListener(myCommoClickListner);
image10.setOnClickListener(myCommoClickListner);
image11.setOnClickListener(myCommoClickListner);
image12.setOnClickListener(myCommoClickListner);
image13.setOnClickListener(myCommoClickListner);
image14.setOnClickListener(myCommoClickListner);
image15.setOnClickListener(myCommoClickListner);
image16.setOnClickListener(myCommoClickListner);
}
LOGCAT
it never adds EXCEPT when the value/number in the textview tv2 and tv3
is set from the properties
You will need to put your code in the onClick button or anything that listen to the user's action. After that, you can get your textview's value and do something with it.
From the look of your code, i suggest you to move all of the initializations in the onCreate:
//move this code to onCreate
score = (TextView)findViewById(R.id.yourScore);
tv2 = (TextView)findViewById(R.id.tv2);
tv3 = (TextView)findViewById(R.id.tv3);
searchWord = (ImageView) findViewById(R.id.searchWord);
wordList = (ListView) findViewById(R.id.wordList);
text = (AutoCompleteTextView) findViewById(R.id.textHere);
wordList = (ListView) findViewById(R.id.wordList);
//also move this
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, new ArrayList<String>());
wordList.setAdapter(adapter);
After that, call your viewWord() in the onClick (or anything you like), example :
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
viewWord(v); //v is your button
}
});
UPDATE
After looking the exception in your logcat, it seems the error occurred because the integer has some whitespaces : "2 " <- a space after 2
Try :
x = Integer.parseInt(tv2.getText().toString().replaceAll("\\s",""));
y = Integer.parseInt(tv3.getText().toString().replaceAll("\\s",""));
The idea is to remove all of the whitespaces before parse it to Integer.
Feel free to comment if you have some questions or if i miss understood you :)
In My App i have 10 Edittext and 10 TextView
I have created instance for the both EditText and TextView like
String[] messageText=new String[10];
String[] messageEdit=new String[10];
TextView oTextView1 = (TextView) findViewById(R.id.Tab_common1_EditText);
TextView oTextView2 = (TextView) findViewById(R.id.Tab_common2_EditText);
TextView oTextView3 = (TextView) findViewById(R.id.Tab_common3_EditText);
TextView oTextView4 = (TextView) findViewById(R.id.Tab_common4_EditText);
TextView oTextView5 = (TextView) findViewById(R.id.Tab_common5_EditText);
TextView oTextView6 = (TextView) findViewById(R.id.Tab_common6_EditText);
TextView oTextView7 = (TextView) findViewById(R.id.Tab_common7_EditText);
TextView oTextView8 = (TextView) findViewById(R.id.Tab_common8_EditText);
TextView oTextView9 = (TextView) findViewById(R.id.Tab_common9_EditText);
TextView oTextView10 = (TextView) findViewById(R.id.Tab_common10_EditText);
EditText oEditTextHiden1 = (EditText) findViewById(R.id.Tab_Hidencommon1_EditText);
EditText oEditTextHiden2 = (EditText) findViewById(R.id.Tab_Hidencommon2_EditText);
EditText oEditTextHiden3 = (EditText) findViewById(R.id.Tab_Hidencommon3_EditText);
EditText oEditTextHiden4 = (EditText) findViewById(R.id.Tab_Hidencommon4_EditText);
EditText oEditTextHiden5 = (EditText) findViewById(R.id.Tab_Hidencommon5_EditText);
EditText oEditTextHiden6 = (EditText) findViewById(R.id.Tab_Hidencommon6_EditText);
EditText oEditTextHiden7 = (EditText) findViewById(R.id.Tab_Hidencommon7_EditText);
EditText oEditTextHiden8 = (EditText) findViewById(R.id.Tab_Hidencommon8_EditText);
EditText oEditTextHiden9 = (EditText) findViewById(R.id.Tab_Hidencommon9_EditText);
EditText oEditTextHiden10 = (EditText) findViewById(R.id.Tab_Hidencommon10_EditText);
now i need to get all the TextView getText() and EditText getText()
I have try some method but it is not working
for (int i = 0; i < 10; i++) {
messageText[i] = (oTextView+i).getText().toString();//it says oTextView cannot be resolved to a variable
messageEdit[i] = (oEditTextHiden+i).getText().toString();
}
Log.i("message", "message :"+Arrays.deepToString(messageText)+" "+Arrays.deepToString(messageEdit));
Store the ids of the EditText and loop over them, since the View ids are integers, you can do that easily like so :
ArrayList<String> values = new ArrayList<String>();
int[] ids = new int[]{R.id.editText1,R.id.editText2,R.id.editText3};//and so on
for(int id : ids){
EditText t = (EditText) findViewById(id);
values.add(t.getText().toString());
}
Or if you only want the text and don't want to do anything else with the EditText view itself, you could make it in one line this:
for(int id : ids) values.add(((EditText)findViewById(id)).getText().toString());
Add all TextView and EdiText in Array Like this
TextView[] oTextView = { oTextView1, oTextView2, oTextView3,
oTextView4, oTextView5, oTextView6, oTextView7, oTextView8,
oTextView9, oTextView10 };
EditText[] oEditTextHiden = { oEditTextHiden1, oEditTextHiden2,
oEditTextHiden3, oEditTextHiden4, oEditTextHiden5,
oEditTextHiden6, oEditTextHiden7, oEditTextHiden8,
oEditTextHiden9, oEditTextHiden10 };
Then getText() Should look like this
for (int i = 0; i < 10; i++) {
messageText[i] = oTextView[i].getText().toString();
messageEdit[i] = oEditTextHiden[i].getText().toString();
}
String[] messageText=new String[10];
String[] messageEdit=new String[10];
TextView[] textViews = new TextView[10];
textViews[0] = (TextView) findViewById(R.id.Tab_common1_EditText);
textViews[1] = (TextView) findViewById(R.id.Tab_common2_EditText);
textViews[2] = (TextView) findViewById(R.id.Tab_common3_EditText);
textViews[3] = (TextView) findViewById(R.id.Tab_common4_EditText);
textViews[4] = (TextView) findViewById(R.id.Tab_common5_EditText);
textViews[5] = (TextView) findViewById(R.id.Tab_common6_EditText);
textViews[6] = (TextView) findViewById(R.id.Tab_common7_EditText);
textViews[7] = (TextView) findViewById(R.id.Tab_common8_EditText);
textViews[8] = (TextView) findViewById(R.id.Tab_common9_EditText);
textViews[9] = (TextView) findViewById(R.id.Tab_common10_EditText);
EditText[] editTexts = new EditText[10];
editTexts[0] = (EditText) findViewById(R.id.Tab_Hidencommon1_EditText);
editTexts[1] = (EditText) findViewById(R.id.Tab_Hidencommon2_EditText);
editTexts[2] = (EditText) findViewById(R.id.Tab_Hidencommon3_EditText);
editTexts[3] = (EditText) findViewById(R.id.Tab_Hidencommon4_EditText);
editTexts[4] = (EditText) findViewById(R.id.Tab_Hidencommon5_EditText);
editTexts[5] = (EditText) findViewById(R.id.Tab_Hidencommon6_EditText);
editTexts[6] = (EditText) findViewById(R.id.Tab_Hidencommon7_EditText);
editTexts[7] = (EditText) findViewById(R.id.Tab_Hidencommon8_EditText);
editTexts[8] = (EditText) findViewById(R.id.Tab_Hidencommon9_EditText);
editTexts[9] = (EditText) findViewById(R.id.Tab_Hidencommon10_EditText);
for (int i = 0; i < 10; i++) {
messageText[i] = textViews[i].getText().toString();
messageEdit[i] = editTexts[i].getText().toString();
}
Log.i("message", "message :"+Arrays.deepToString(messageText)+" "+Arrays.deepToString(messageEdit));
The best way to do this is to use the tag associated with the textview.
For example :
In Xml you need to create TextView and editText as following :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/llParent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:tag="tv1"
android:text="TextView1" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:tag="et1"
android:text="EditText1" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:tag="tv2"
android:text="TextView2" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:tag="et2"
android:text="EditText2" />
===== Similarly 10 Textviews and EditTexts========
</LinearLayout>
In Code :
String[] messageText = new String[10];
String[] messageEdit = new String[10];
LinearLayout llParent = (LinearLayout) findViewById(R.id.llParent);
for (int i = 1; i <= 10; i++) {
messageText[i - 1] = ((TextView) llParent.findViewWithTag("tv" + i))
.getText().toString();
messageEdit[i - 1] = ((EditText) llParent.findViewWithTag("et" + i))
.getText().toString();
}
Happy Coding.... :-)
Try Like This :-
ArrayList<TextView> arrayListTextViews = new ArrayList<TextView>();
TextView oTextView1 = (TextView) findViewById(R.id.Tab_common1_EditText);
TextView oTextView2 = (TextView) findViewById(R.id.Tab_common2_EditText);
TextView oTextView3 = (TextView) findViewById(R.id.Tab_common3_EditText);
TextView oTextView4 = (TextView) findViewById(R.id.Tab_common4_EditText);
TextView oTextView5 = (TextView) findViewById(R.id.Tab_common5_EditText);
TextView oTextView6 = (TextView) findViewById(R.id.Tab_common6_EditText);
TextView oTextView7 = (TextView) findViewById(R.id.Tab_common7_EditText);
TextView oTextView8 = (TextView) findViewById(R.id.Tab_common8_EditText);
TextView oTextView9 = (TextView) findViewById(R.id.Tab_common9_EditText);
TextView oTextView10 = (TextView) findViewById(R.id.Tab_common10_EditText);
arrayListTextViews.add(oTextView1);
arrayListTextViews.add(oTextView2);
arrayListTextViews.add(oTextView3);
arrayListTextViews.add(oTextView4);
arrayListTextViews.add(oTextView5);
arrayListTextViews.add(oTextView6);
arrayListTextViews.add(oTextView7);
arrayListTextViews.add(oTextView8);
arrayListTextViews.add(oTextView9);
arrayListTextViews.add(oTextView10);
and then access textviews from arrayListTextViews in the loop.
Also do the same for Your Edittext.
the best way is to use the getIdentifier method in the Resources class
something like that
messageText[i] = (TextView) getActivity().findViewById(getResources().getIdentifier("Tab_common"+i+"_EditText", "id", context.getPackageName()));
messageEdit[i] = (EditText) getActivity().findViewById(getResources().getIdentifier("Tab_Hidencommon"+i+"_EditText", "id", context.getPackageName()));
I used the answer to this question to get the basic value of the TextView clicks into a single TextView .This code gives a per click value, I want to know how to add the existing value of TextView.
Note: m1aa and m1ab are number variables in a previous activity and received through intent on this one.
UPDATE This question should have been "how do you convert a string to a decimal."
//Original non working code.
private int productTotal1;
private int productTotal2;
private int overallTotalproduct;
private TextView m1a,
private TextView m1aa,
//and then way down the page
productTotal1 = 0;
productTotal2 = 0;
overallTotalproduct = 0;
final TextView textViewtotalproduct = (TextView) findViewById(R.id.total);
final TextView textView1 = (TextView) findViewById(R.id.m1aa);
final TextView textView2 = (TextView) findViewById(R.id.m1ab);
textView1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
productTotal1++;
overallTotalproduct = productTotal1 + productTotal2;
textView1.setText(String.valueOf(productTotal1));
textViewtotalproduct.setText(String.valueOf(overallTotalproduct));
}
});
textView2.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
productTotal2++;
overallTotalproduct = productTotal1 + productTotal2;
textView2.setText(String.valueOf(productTotal2));
textViewtotalproduct.setText(String.valueOf(overallTotalproduct));
}
});
***UPDATE***WORKS FINE :)
AFTER GETTING HELP AND "THINKING" ABOUT WHAT I WAS WRITING I END UP WITH...
//Working version
private double overallTotalproduct;
final TextView textViewtotalproduct = (TextView) findViewById(R.id.total);
final TextView textView1 = (TextView) findViewById(R.id.m1aa);
final String stringm1aa = textView1.getText().toString();
final double intm1aa = Double.parseDouble(stringm1aa);
final TextView textView2 = (TextView) findViewById(R.id.m1ab);
final String stringm1ab = textView2.getText().toString();
final double intm1ab = Double.parseDouble(stringm1ab);
You can use following code to get a value of TextView and convert it to integer
String s = textView.getText().toString();
int n = Integer.parseInt(s);
Remember NumberFormatException will be thrown if the string does not contain a parsable integer.
how to create the textview in code not in xml file. It is because number of textviews will be changing in my application according to some integer.
This is the code to create TextView Dynamically
LinearLayout layout = (LinearLayout ) findViewById(R.id.llayout);
for (int i = 0; i < 3; i++) {
TextView dynamicTextView = new TextView(this);
dynamicTextView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
dynamicTextView.setText("NewYork");
layout.addView(tstate);
}
Maybe thats what you need:
LinearLayout lin = (LinearLayout) findViewById(R.id.myLinear);
for (int i = 0; i <= 10 ; i++)
{
TextView myText = new TextView(this);
myText.setText("textview# "+ i);
lin.addView(myText);
}
Something like the following should be what you need:
final int N = 10; // total number of textviews to add
final TextView[] myTextViews = new TextView[N]; // create an empty array;
for (int i = 0; i < N; i++) {
// create a new textview
final TextView rowTextView = new TextView(this);
// set some properties of rowTextView or something
rowTextView.setText("This is TextView #" + i);
// add the textview to the linearlayout
myLinearLayout.addView(rowTextView);
// save a reference to the textview for later
myTextViews[i] = rowTextView;
}
private LinearLayout ll;
private TextView tv;
// in oncreate()
onCreate()
{
int WrapWidth = LinearLayout.LayoutParams.WRAP_CONTENT;
int WrapHeight = LinearLayout.LayoutParams.WRAP_CONTENT;
tv = new TextView(this);
ll.addView(tv,WrapWidth,WrapHeight);
}
Code is here
final int c = 12;
final TextView[] mtext = new TextView[c];
for (int i = 0; i < c; i++) {
TextView rowtxt = new TextView(this);
rowtxt.setText("Hello" + i);
myLinearLayout.addView(rowtxt);
myTextViews[i] = rowtxt;
myTextViews[i].setOnClickListener(onclicklistener);//textview click
}
OnClickListeners code is here
OnClickListener onclicklistener = new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(v == myTextViews[0]){
//do whatever you want....
}
}
};
Hope it is helpful for you
You use TextView textView = new TextView(CurrentActivity.this);
and then you add setter arguments that come with the TextView class