【发布时间】:2014-04-11 09:49:10
【问题描述】:
我是Android新手,如果我的问题如此愚蠢,请道歉!
我在公共类中创建了一个新的 TextView,但是当我想为其分配 ID 时,[我尝试了 text1.setID(1)],但 Eclipse 无法识别 text1。
有什么问题?我是不是把 TextView 定义错了?
实际上我的目标是创建一个包含 2 个 textViews(text1 & text2) 的类(这里是 Class Post),然后我想在我的程序中从这个类创建对象(例如在主要活动中),这是一个正确的方法? (一种简单地创建新的android小部件)
public class Post{
Context Creator_Context;
public Post(Context context)
{
ctx= context;
}
//Creating a textview.
TextView text1 = new TextView(Ctx);
TextView text2 = new TextView(Ctx);
///////here is the PROBLEM////// :
text1.setID(1);
}
谢谢,
【问题讨论】:
标签: java android xml eclipse android-widget