[android-developers] Scroll Event in Android
I am developing an app in which i am using random numbers to retrieve
data from my database and drawable from an array. Here is my code:
public class Facts extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
int factNo, imgNo;
int[] bgNo={2130837505, 2130837516, 2130837525, 2130837526,
2130837527,
2130837528, 2130837529, 2130837530, 2130837531, 2130837506,
2130837507, 2130837508, 2130837509, 2130837510, 2130837511,
2130837512, 2130837513, 2130837514, 2130837515, 2130837517,
2130837518, 2130837519, 2130837520, 2130837521, 2130837522,
2130837523, 2130837524};
Random rand = new Random();
//for(int i=1;i<=636;i++)
//{
factNo = rand.nextInt(636);
imgNo = rand.nextInt(27);
//}
TextView tv = new TextView(this);
ScrollView sv = new ScrollView(this);
DBAdapter db = new DBAdapter(this);
/*
db.open();
long id;
for(int i = 1;i<=636;i++)
{
id = db.insertFact("Sex Fact " + i);
}
*/
db.open();
Cursor c = db.getFact(factNo);
if (c.moveToFirst())
{
// db.displayFact(c);
// Toast.makeText(this, c.getString(1),
Toast.LENGTH_LONG).show();
tv.setPadding(50, 200, 50, 200);
tv.setBackgroundResource(bgNo[imgNo]);
//tv.setBackgroundResource(imgNo);
tv.setText(c.getString(1));
tv.scrollBy(0, 400);
setContentView(tv);
}
else
{
Toast.makeText(this, "No title found",
Toast.LENGTH_LONG).show();
}
db.close();
}
My requirement is to do the same thing on a scroll event instead of on
create event. How is that possible?
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home