mardi 23 juin 2015

java.lang.RuntimeException: Unable to start activity ComponentInfo{}

i created an expandablelist, now i want to store the child i click in database and then view the data

main screen

public class MAINscreen extends ActionBarActivity {
Button menubtn, vieworderbtn;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.mainscreen);

    menubtn=(Button)findViewById(R.id.menubutton1);
    vieworderbtn=(Button)findViewById(R.id.vieworderbtn);

     menubtn.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View arg0) {
                Intent loginintent=new Intent(getApplicationContext(),MenuViewforCust.class);
                startActivity(loginintent);

            }
        });

     vieworderbtn.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View arg0) {
                Intent loginintent=new Intent(getApplicationContext(),ViewallEMP.class);
                startActivity(loginintent);

            }
        });
}

class holdin list data

public class MenuViewforCust extends ActionBarActivity {

DBhandle dbhandle;

List<String> groupList;
List<String> childList;
Map<String, List<String>> laptopCollection;
ExpandableListView expListView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.menu_viewfor_cust);

    dbhandle=new DBhandle(this);
    dbhandle=dbhandle.open();

    createGroupList();

    createCollection();

    expListView = (ExpandableListView) findViewById(R.id.menuexpandableListView1);
    final ExpandableListAdapter expListAdapter = new ExpandableListAdapter(
            this, groupList, laptopCollection);
    expListView.setAdapter(expListAdapter);       

    expListView.setOnChildClickListener(new OnChildClickListener() {
        public boolean onChildClick(ExpandableListView parent, View v,
                int groupPosition, int childPosition, long id) {
            final String selected = (String) expListAdapter.getChild(groupPosition, childPosition);
            Toast.makeText(getBaseContext(), selected, Toast.LENGTH_LONG).show();

            dbhandle.insertOrder(selected);

            return true;
        }
    });

}

private void createGroupList() {
    groupList = new ArrayList<String>();
    groupList.add("Starters");
    groupList.add("Pastries");
}

private void createCollection() {
    // preparing laptops collection(child)
    String[] starter = { "Veg Manchurian Dry- 85Rs","Veg Roll- 80Rs","Paneer Manchurian- 95Rs" };

    String[] pastrie = {"Black forest- 65Rs","White Forest- 65Rs","Pina Strawbery- 55Rs" };

    laptopCollection = new LinkedHashMap<String, List<String>>();

    for (String laptop : groupList) {
        if (laptop.equals("Starters")) {
            loadChild(starter);
        } else 
            loadChild(pastrie);

        laptopCollection.put(laptop, childList);
    }
}

private void loadChild(String[] laptopModels) {
    childList = new ArrayList<String>();
    for (String model : laptopModels)
        childList.add(model);

}

class to view data

public class ViewallEMP extends ActionBarActivity {

Button viewempbtn;
DBhandle dbhandle;
TextView viewallemp;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.viewall_emp);

    dbhandle=new DBhandle(this);
    dbhandle=dbhandle.open();

    viewallemp=(TextView)findViewById(R.id.showtextView1);
    viewfinalorderbtn=(Button)findViewById(R.id.vieworderbtn);

    viewfinalorderbtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            dbhandle.getOrderData();
            String orderdata=dbhandle.getEMPData();
            viewallemp.setText(orderdata);

        }
    });

}

Now when i click the vieworderbtn on MAINscreen app crashes with following error. line 44 is viewfinalorderbtn.setOnClickListener(new View.OnClickListener() I searched for an solution but could not find it any help would be appreciated. I am new to android Pls forgive me if it's childish

logcat

Aucun commentaire:

Enregistrer un commentaire