I has to ask you how to find my Views, I created them dynamically because all information about Texts were in my string-array, and now I would like to find it to store this in Class by getters, to use it in another classes, in feature I would like to make backend to store information thats why I chose class for temporary solution.
Thats my code
sportlist = getResources().getStringArray(R.array.btnsport);
for(j=0;j<sportlist.length;j++){
sporthash.put(j,sportlist[j]);
System.out.println(sporthash);
}
//Here I create my TableRow with TextView
TableRow.LayoutParams lp = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT);
lp.height = 120;
lp.setMargins(8,8,8,8);
for(j=0;j<sportlist.length;j++) {
TableRow row = new TableRow(getActivity());
row.setLayoutParams(lp);
final TextView t = new TextView(getActivity());
t.setPadding(10, 10, 10, 10);
t.setText(sporthash.get(j));
t.setGravity(Gravity.CENTER);
t.setClickable(true);
t.setTextSize(18);
t.setId(j);
t.setBackgroundResource(R.drawable.sport_false);
t.setTextColor(Color.BLACK);
Then after this I have saving button, which send information to my Storage.class. I try to set t.setId(j)
and find it by new TextView
h, h.findViewById(j)
but its return strage code. I would to find Views with t.BackgroundResource(R.drawable.sport_true)
and send them to my Storage.class.
Thats my button, in for I tryed to find my views, so what solution would be best ?
save.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Storage sto = new Storage();
sto.setAge(BirthDate.getText().toString());
sto.setImage(civ);
sto.setLocation(Map.getText().toString());
System.out.println(Map.getText().toString());
for(j=0;j<sportlist.length;j++) {
}
Intent newIntent = new Intent(getActivity(),ProfilActivity.class);
startActivity(newIntent);
}
});