我通常使用eclipse或NetBeans创建Android应用程序但是当我尝试按下按钮时创建消息框时,Eclipse在这种情况下不会导入javax.swing
activity_main.xml中:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="136dp"
android:text="Button" />
</RelativeLayout>
MainActivity.java:
package com.example.understanding;
import android.os.Bundle;
import android.app.Activity;
import javax.swing;
import android.view.Menu;
import android.view.View;
public class MainActivity extends Activity {
private void button1_ButtonActionPerformed(View v) {
JOptionPane.showMessageDialog(null, "Enter Account Details");
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}