I need to pass int value i to other class, because it's the id from a database, but it doesn't allow me to pass the int value using .putExtra, because the value needs to be int, but if I declare that value as final then it can't change anymore for the loop.. Help, thanks.
final int x = DataBaseHelper.getLastId();
int i = 0;
final TextView[] textViews = new TextView[x];
while (i < x) {
TextView newTextView = new TextView(this);
newTextView.setText(DataBaseHelper.getTitleNow(i + 1) + " \n");
newTextView.setInputType(newTextView.getInputType() | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
newTextView.setLayoutParams(new LayoutParams((LayoutParams.WRAP_CONTENT), ViewGroup.LayoutParams.WRAP_CONTENT));
newTextView.setClickable(true);
newTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent(HistoryActivity.this, MainActivity.class);
intent.putExtra("ID", i);
startActivity(intent);
finish();
}
});
ll.addView(newTextView, layoutParams);
textViews[i] = newTextView;
i++;
}