【发布时间】:2013-11-20 09:54:38
【问题描述】:
我有两个班级,一个是public class range extends LinearLayout。
另一个是public class Main extends Activity
在 Main 中,我使用 MyWindowManager.createBigWindow(getApplicationContext()); 来调用 range 类。
范围类:
public class Out_of_range extends LinearLayout {
public static int viewWidth;
public static int viewHeight;
public Out_of_range(final Context context) {
super(context);
// TODO Auto-generated constructor stub
LayoutInflater.from(context).inflate(R.layout.out_of_range, this);
View view = findViewById(R.id.big_window_layout);
viewWidth = view.getLayoutParams().width;
viewHeight = view.getLayoutParams().height;
TextView text = (TextView)findViewById(R.id.text);
text.setText("loss :"+ Main.tempAddress);
Button back = (Button)findViewById(R.id.back);
back.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
/*----------------------------------------------------------------------------------------------
//I want to start Activity when I click the button here.
final Intent mainintent = new Intent(getContext(), Main.class);
startActivity(mainintent);
*/-----------------------------------------------------------------------------------------------
}
});
}
我想从一个类开始 Activity(这个类扩展了 LinearLayout)
我使用了 intent ,但它有错误。
未定义类型 new View.OnClickListener(){}
的方法 startActivity(Intent)【问题讨论】:
-
你不能重写你的范围类中的构造函数来把你的字符串值作为参数吗?或者你也可以在你的范围类中添加一个字符串值,并使用 getter/setter 访问它。
-
@DamienR.:sorry...第一个问题我听不懂。
标签: android android-linearlayout android-4.3-jelly-bean