开发者

using results of db select (in list<string>) to compile a new intent to change class

Apologies, am new to android, so this may be a very silly question.

Would really appreciate any help though.

In android I have a table in a db which updates based upon some stuff that a user does. Based upon the content of that table I then decide what page (or class with a layout) in my app that I want the user to see next.

So for example, if the table says the user is male and 60, I know I want the user to see 'page' 2 next. If the user is female and 20, I want them to see开发者_StackOverflow 'page' 3 next.

I have succesfully created a simple select query which pulls back the 'page' number I want to go to next (my page numbers are the same as my class names). It pulls it back as a list<string> (with only one value).

My question is, how do I load a class based upon the results of this query?

i.e. in myonclicklistener how do I compile my NEXTCLASS based on the value held in my list?

public void onClick(View view) {
Intent myIntent = new Intent(view.getContext(), NEXTCLASS.class);
startActivity(myIntent);#

Im sorry this is a terrible question - any help would be really appreciated.

Thanks!


Maybe you should use intent filter and start activitites view intent with action (public Intent (String action) ). You can declare intent filter in manifest file for each "page" activity. You can create string, which first part - is yours package name, and second part - the data which you get from database.

List<String> dbResultList = // get data from db        
String first = "my.package.";
String dbResult = dbResultList.get(0); // for example "PAGE_3" is the value, returned from db

Then create intent with new Intent(first+dbResult) - an activity which has an intent with action my.package.PAGE_3 in manifest should start.

Of course you should write class and layout for each page (of course if every page has it own logic and interface)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜