Scroll Event in Android

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Scroll Event in Android

Postby Maxood » Wed Nov 04, 2009 3:15 pm

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?
Maxood

"Life is an endless journey to achieve perfection"
Maxood
Developer
Developer
 
Posts: 34
Joined: Sun Aug 02, 2009 1:37 pm
Location: Karachi, Pakistan

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 8 guests