I am new at creating UI Java apps and am trying to create an app that starts with a list of items (ListView) to choose from and then open the corresponding package. I have created the list along with one of the many packages and they both work independently. My problem is I cannot figure out for the life of me how to call the selected "module" from the list. Here is the list code:
package com.constructioncalc.main;
import com.example.squarefeet.*;
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;
public class ConstructionCalc extends ListActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, CALCULATORS));
ListView lv = getListView();
lv.setTextFilterEnabled(true);
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// When clicked, goto selected package
DO SOMETHING HERE
}
});
}
static final String[] CALCULATORS = new String[] {
"Square Feet"
};
}
package com.constructioncalc.main;
import com.example.squarefeet.*;
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;
public class ConstructionCalc extends ListActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, CALCULATORS));
ListView lv = getListView();
lv.setTextFilterEnabled(true);
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// When clicked, goto selected package
DO SOMETHING HERE
}
});
}
static final String[] CALCULATORS = new String[] {
"Square Feet"
};
}