我有兩個班,一個是public class range extends LinearLayout
。如何在Android 4.3中啓動類(該類擴展了LinearLayout)的Activity?
另一個是public class Main extends Activity
在主,我使用MyWindowManager.createBigWindow(getApplicationContext());
調用範圍類。
範圍類:
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);
*/-----------------------------------------------------------------------------------------------
}
});
}
,我想從一個班開始活動(此類擴展的LinearLayout)
我使用的意圖,但它有錯誤。
方法startActivity(意向)是未定義的類型新View.OnClickListener(){}
你不能重寫你的範圍類中的構造函數來將你的字符串值作爲參數嗎? 或者您也可以在您的範圍類中添加一個字符串值,並使用getter/setter訪問它。 –
@DamienR。:對不起......我不明白第一個問題。 – Wun