在特殊情况下,我需要从我的活动中删除对话框主题,但它似乎不起作用.这是一个例子
第一项活动:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
startActivity(new Intent(MainActivity.this, SecondActivity.class));
}
Run Code Online (Sandbox Code Playgroud)
第二项活动:
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setTheme(android.R.style.Theme);
setContentView(R.layout.activity_second);
}
Run Code Online (Sandbox Code Playgroud)
清单摘录:
<activity android:name="SecondActivity" android:theme="@android:style/Theme.Dialog"></activity>
Run Code Online (Sandbox Code Playgroud)
当我运行它仍然是对话主题.
API10
谢谢.
我有一个带有两个editexts的布局.我需要设置第二个焦点,并在第一个点击输入键时进行编辑.我有设置焦点的代码但是当第二个获得焦点时我无法开始输入.
PS我还需要edittext正好一行高,不可能制作附加行.它也有效.pss android 2.3
XML代码:
<EditText
android:id="@+id/email"
style="@style/profileLoginInput"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:hint="@string/email" android:ems="10" android:lines="1" android:maxLines="1" android:ellipsize="end">
<requestFocus />
</EditText>
<EditText
android:id="@+id/password"
style="@style/profileLoginInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:ems="10"
android:inputType="textPassword" android:hint="@string/password">
Run Code Online (Sandbox Code Playgroud)
Java代码:
((EditText) findViewById(R.id.email)).setOnKeyListener(new OnKeyListener(){
@Override
public boolean onKey(View v, int keyCode, KeyEvent event)
{
if (event.getAction() == KeyEvent.ACTION_DOWN)
{
switch (keyCode)
{
case KeyEvent.KEYCODE_DPAD_CENTER:
case KeyEvent.KEYCODE_ENTER:
((EditText) findViewById(R.id.password)).requestFocus();
return true;
default:
break;
}
}
return false;
}
});
Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我需要处理物理按钮事件,例如音量按钮点击.为此,我使用了audiomanager的registerMediaButtonEventReceiver方法.有一篇文章与我的情况有关,虽然我无法让它发挥作用.
这是我正在使用的代码:
public class VolumeBroadcastActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
AudioManager manager = (AudioManager) getSystemService(AUDIO_SERVICE);
manager.registerMediaButtonEventReceiver(new ComponentName(getPackageName(), RemoteControlReceiver.class.getName()));
}
public class RemoteControlReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(VolumeBroadcastActivity.this, "1",1).show();
if (Intent.ACTION_MEDIA_BUTTON.equals(intent.getAction())) {
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="localhost.volume.broadcast"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".VolumeBroadcastActivity"
android:label="@string/app_name" >
<intent-filter> …Run Code Online (Sandbox Code Playgroud) 我试图像这样使用setConnectTimeout函数:
protected HttpURLConnection getConnection() throws SocketTimeoutException, IOException{
Log.d("HTTPRequest", address);
URL page = new URL(address);
HttpURLConnection connection = (HttpURLConnection) page.openConnection();
connection.setUseCaches(cacheResult);
connection.setConnectTimeout(3000);
connection.connect();
return connection;
}
Run Code Online (Sandbox Code Playgroud)
然后:
public String getTextData() throws InternetConnectionUnavailableException {
try{
HttpURLConnection conn = getConnection();
StringBuffer text = new StringBuffer();
InputStreamReader in = new InputStreamReader((InputStream) conn.getContent());
BufferedReader buff = new BufferedReader(in);
String line;
while (true) {
if((line = buff.readLine()) != null){
text.append(line);
}else{
break;
}
}
return (text.toString());
} catch (SocketTimeoutException socketTimeoutException) {
throw new InternetConnectionUnavailableException();
} catch …Run Code Online (Sandbox Code Playgroud) 我用它来获取当前时间戳,以秒为单位并将其添加到字符串Double.toString((System.currentTimeMillis()/1000))
但是不是十进制表示法,而是"1.23213E9".如何切换到十进制表示法?