我正在使用新的GoogleMaps API(v2)并且片段存在一些问题.我的应用程序(Map,List)中有两个片段,用户可以在它们之间切换.到目前为止使用此代码正常工作:
if (itemPosition == 0) {
getSupportFragmentManager().beginTransaction()
.replace(R.id.fragmentpos, myMapFragment).commit();
} else if (itemPosition == 1) {
getSupportFragmentManager().beginTransaction()
.replace(R.id.fragmentpos, myListFragment).commit();
}......
Run Code Online (Sandbox Code Playgroud)
当我使用地图时,切换到列表片段,然后返回到地图片段,不保存地图的最后位置.这不是我想要的,我希望地图处于保存状态,因为我"离开"它..我怎么能完成这个?我试图保存相机的位置
public void onSaveInstanceState(Bundle outState){
outState.putDouble("LAT", mMap.getCameraPosition().target.latitude);
outState.putDouble("LON", mMap.getCameraPosition().target.longitude);
outState.putFloat("BEAR", mMap.getCameraPosition().bearing);
...
Run Code Online (Sandbox Code Playgroud)
}
并在onCreateView()中恢复它,但Bundle始终为null.如果我替换片段,则不会调用onSaveInstanceState.
那么如何保存地图的状态呢?
android android-maps android-fragments android-fragmentactivity
如果太大,是否有可能使Android ActionBar的标题自动滚动(选取框)?
我有一个音乐流应用程序,我想在音乐流媒体时显示前景通知.我在单独的服务中进行流式传输,我用于前台通知的代码如下:
Notification notification = new Notification(R.drawable.ic_stat_notification, getString(R.string.app_name), System.currentTimeMillis());
Intent notificationIntent = new Intent(this, PlayerActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.setLatestEventInfo(this,getString(R.string.app_name),
getString(R.string.streaming), pendingIntent);
startForeground(4711, notification);
Run Code Online (Sandbox Code Playgroud)
该符号显示在任务栏中,如果我点击该通知应用程序打开,但它是一个全新的活动(我猜是因为创建了一个新的Intent).因此,如果我在应用程序中打开了一个对话框,如果我关闭应用程序(单击主页)然后在通知栏中单击/单击应用程序图标,则该对话框无法打开.我该如何处理这个以便显示"旧/真实"活动?
android android-intent android-service android-notifications android-pendingintent
我是使用JAXB的新手,我现在正在努力解决问题.也许你可以帮助我.
我有以下代码:
@XmlRootElement
public class Students implements Serializable{
private static final long serialVersionUID = 1L;
private List<Person> personList;
private int id;
// getters and setters for the attributes
}
Run Code Online (Sandbox Code Playgroud)
和
@XmlRootElement
public class Person implements Serializable {
private static final long serialVersionUID = 1L;
private String name;
private int sex;
//getters and setters for the attributes
}
Run Code Online (Sandbox Code Playgroud)
当我尝试用JAXB封送学生时,我只在结果字符串中有id-Element.我没有名单(人).这里的问题在哪里?
在选择特定的EditText之前,如何防止软键盘消失?打开时,我的布局中有几个EditTexts,第一个自动选择并显示软件键盘.
我知道我可以通过设置android:focusable ="false"来禁用它.但是,无法点击该项目并显示该项目.
我想要的:活动开始,用户看到所有EditTexts,然后他点击一个,打开软件键盘,可以在EditText中输入内容.这可能吗?