在虚拟手机菜单中显示。但它没有显示在我的个人手机中。我在这里保留了mainactivity.java
,main.xml
,androidmainfest.xml
个文件。请回答任何问题...... < / p>
//mainactivity.java
public class MainActivity extends Activity{
String username,password; ResultSet rs =null;
boolean temcfag=false;
static boolean temqfag=true;
public static String tag="Lifecycle activity";
EditText user,pass;
AlertDialog.Builder dialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
dialog=new AlertDialog.Builder(this);
dialog.setNeutralButton("OK", null);
user=(EditText)findViewById(R.id.editText1);
pass=(EditText)findViewById(R.id.editText2);
final Button click=(Button)findViewById(R.id.button2);
click.setOnClickListener(new View.OnClickListener() {
public void onClick(View v)
{
Intent launchactivity= new Intent(MainActivity.this,com.example.desisquarea.LoginActivity.class);
startActivity(launchactivity);
}
});
}
@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;
}
}
//menu/main.xml
<?xml version="1.0" ?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/login" android:title="SignUP" />
<item android:id="@+id/sign" android:title="Login" />
<item android:id="@+id/home" android:title="Home" />
</menu>
//androidmainfest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.desisquarea"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.desisquarea.MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
答案 0 :(得分:-1)
LayoutParams lp = dialog.getWindow().getAttributes();
lp.gravity = Gravity.TOP | Gravity.RIGHT;
myDialog.getWindow().setAttributes(lp);
dialog.show();