android - Complete code for calling the object of category.java in main activity -
i have class name category.java
in eclipse , want display attributes of through mainactivity.java
calling object of category.java
in mainactivity.java
.
how can ?
category.java file
package com.example.tabstest; public class catagory { private int id; private string name; private string desc; private int image; public catagory(int id, string name, string desc) { super(); this.id = id; this.name = name; this.desc = desc; } public catagory(int id, string name, string desc, int image) { super(); this.id = id; this.name = name; this.desc = desc; this.image = image; } public int getid() { return id; } public void setid(int id) { this.id = id; } public string getname() { return name; } public void setname(string name) { this.name = name; } public string getdesc() { return desc; } public void setdesc(string desc) { this.desc = desc; } public int getimage() { return image; } public void setimage(int image) { this.image = image; } }
try following can access following way,
write following code in main activity's oncreate().
imageview ivimage=(imageview)findviewbyid(r.id.ivimage); catagory catagory=new catagory(1, "abc", "this set value",r.drawable.ic_launcher); int id=catagory.getid(); string name=catagory.getname(); string desc=catagory.getdesc(); int image=catagory.getimage(); log.v("id", "id="+id); log.v("name", "name="+id); log.v("desc", "desc="+id); ivimage.setimageresource(image);
Comments
Post a Comment