Starter help

Put your problem here if it does not fit any of the other categories.

Starter help

Postby solo » Fri Mar 25, 2011 9:55 pm

Hi all,

I am going to create a application that looks just like my mobile website, but i need some help to get startet correctly.
The website is a cook book with recipes. It has categories, subcategories and recipes.
The mobile website is located here: http://m.abcoppskrifter.com/

Can anyone please help me at this point on showing me the next step?

ABCoppskrifter.java
Code: Select all
package com.abcoppskrifter.m;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;


public class ABCoppskriftercom extends ListActivity {
   @Override
   public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      
      /*- Variables ------------------------------------------- */
      int category = 0;
      
      if(category == 0){
         /*- Main categories ---------------------------------------------------- */
         String[] mainCategories = getResources().getStringArray(R.array.main_categories_array);
         setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, mainCategories));
         
         ListView lv = getListView();
         lv.setTextFilterEnabled(true);

         lv.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
               // When clicked, show a toast with the TextView text
               // Toast.makeText(getApplicationContext(), "Invalid Value(s) Entered in \"Values\" Field", Toast.LENGTH_LONG).show();
               category++;
              }
           });
        }
      if(category > 0){
         /*- Display sub categories ---------------------------------------------------- */
       
        }
   }
}


strings.xml
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="hello">Hello World, ABCoppskriftercom!</string>
    <string name="app_name">ABC oppskrifter</string>
   
    <string-array name="main_categories_array">
        <item>Bake</item>
        <item>Foretter</item>
        <item>Hovedretter</item>
        <item>Småretter</item>
    </string-array>
   
</resources>
~ Asking if computers can think is like asking if submarines can swim.
User avatar
solo
Junior Developer
Junior Developer
 
Posts: 22
Joined: Fri Mar 25, 2011 9:51 pm

Top

Re: Starter help

Postby Nomad0404 » Wed Mar 30, 2011 1:47 pm

For each subset of options you have I'd have a new Activity and .xml file.

To start with you have some basic red buttons which you can fairly easily reproduce in the XML and colour them with


Then you simply program your button to call the new activity via an intent.
Code: Select all
final Button button1 = (Button) findViewById(R.id.buttonIDinXML);

button1.setOnClickListener(new View.OnClickListener()
{
            public void onClick(View arg0)
            {
                      Intent intent = new Intent(CurrentActivity.this, NewActivity.class);             
                       startActivity(intent);
            }
});


Using that you should be able to create the basic navigation for your sight reproduced in your phone.

Don't forget every activity you create has to be referred to by the manifest.

For example:

Code: Select all
<activity android:name="nameOfActivity"
              android:label="activityLabel">
      </activity>
Nomad0404
Junior Developer
Junior Developer
 
Posts: 19
Joined: Mon Mar 07, 2011 10:23 pm

Re: Starter help

Postby solo » Fri Apr 01, 2011 9:35 pm

Thank you very much! That is a great idea.
~ Asking if computers can think is like asking if submarines can swim.
User avatar
solo
Junior Developer
Junior Developer
 
Posts: 22
Joined: Fri Mar 25, 2011 9:51 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 22 guests