我尝试创建一个模型类,就像我们在Eclipse ADT中所做的那样,只需创建一个文件夹并引用它,但在Android Studio中,我有点困惑。如何在Android Studio中创建模型类,如果我右键单击包-〉新建-〉,哪个文件夹是合适的?
b09cbbtk1#
你可以这样做右键单击任何包,如com.example.setu,然后单击New->package。这里只需要给予名称,如model。然后它会在该包下创建一个文件夹。您可以在此处添加POJO类,只需右键单击New-〉Java类
com.example.setu
New->package
model
7cjasjjr2#
您可以通过简单的步骤创建模型类
public class Wallet_Model { String date, amount, storeid, storename, description, type; public Wallet_Model(String date, String amount, String storeid, String storename, String description, String type) { this.date = date; this.amount = amount; this.storeid = storeid; this.storename = storename; this.description = description; this.type = type; } public Wallet_Model() { } public String getDate() { return date; } public void setDate(String date) { this.date = date; } public String getAmount() { return amount; } public void setAmount(String amount) { this.amount = amount; } public String getStoreid() { return storeid; } public void setStoreid(String storeid) { this.storeid = storeid; } public String getStorename() { return storename; } public void setStorename(String storename) { this.storename = storename; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public String getType() { return type; } public void setType(String type) { this.type = type; } }
2条答案
按热度按时间b09cbbtk1#
你可以这样做
右键单击任何包,如
com.example.setu
,然后单击New->package
。这里只需要给予名称,如model
。然后它会在该包下创建一个文件夹。您可以在此处添加POJO类,只需右键单击New-〉Java类7cjasjjr2#
您可以通过简单的步骤创建模型类