我用一些标签写了一个FragmentActivity.当我用startActivityForResult调用一个额外的活动(我用它来设置用户首选项)时(如果它在FragmentActivity或ListFragment中没有差异),当我启动这个首选项活动时,会调用onActivityResult方法,但不会在我完成它时调用我期待它(如果它在FragmentActivity或ListFragment中再没有差异).在完成首选项活动后,此方法根本不会被调用.
我的问题是,我想在完成首选项活动后刷新当前选项卡(并设置最后使用的选项卡ID),我希望能够在onActivityResult方法中执行此操作.
这是创建首选项活动的类:
public abstract class ListFragmentBase<I> extends ListFragment implements
LoaderCallbacks<List<I>> {
Run Code Online (Sandbox Code Playgroud)
这是将我转发到此类中的首选项活动的方法:
protected void forwardToPreferences(int currentTab){
Intent intent = new Intent(getActivity(), GlobalPreferencesActivity.class);
getActivity().startActivityForResult(intent, 10);
}
Run Code Online (Sandbox Code Playgroud)
这是在调用上面的方法之后调用的方法,而不是在我完成被调用的活动之后调用的方法
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
}
Run Code Online (Sandbox Code Playgroud)
这是偏好活动:
public class GlobalPreferencesActivity extends Activity {
Run Code Online (Sandbox Code Playgroud)
在那个课程中你会看到我如何调用finish方法:
TextView confirmSettings = (TextView) view.findViewById(R.id.confirm_settings);
confirmSettings.setTextSize(PreferenceHelper.getSizeHeader(getApplicationContext()));
confirmSettings.findViewById(R.id.confirm_settings).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(BaseFragmentActivity.lastActivity != null){
BaseFragmentActivity.lastActivity.onRefreshData();
}
ComponentName callingActivity = getCallingActivity();
GlobalPreferencesActivity.this.finish();
}
});
Run Code Online (Sandbox Code Playgroud) 我正在编写一个应用程序,在弹出窗口中显示未接来电和未读短信.它还有一个提醒功能(关闭弹出窗口并在指定时间后打开它).它类似于any.do的弹出窗口.
我能够通过使用WindowManger创建这样一个窗口,但由于某些我目前尚不理解的原因,弹出窗口在一段时间后消失(虽然它应该被打开,直到用户关闭它,或点击提醒按钮)这可能需要几个小时).
这就是我创建现有弹出窗口的方式
windowManager = (WindowManager) context.getApplicationContext()
.getSystemService(Context.WINDOW_SERVICE);
this.inflater = LayoutInflater.from(context);
params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_PHONE,
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
+ WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
+ WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT);
params.gravity = Gravity.BOTTOM;
vgPopupWindow = (ViewGroup) LayoutInflater.from(context).inflate(R.layout.popup_mainwindow, null);
vgPopupContent = (ViewFlipper) vgPopupWindow.findViewById(R.id.popup_content);
vgPopupAreaContent = (ViewGroup) vgPopupWindow.findViewById(R.id.popup_area_content);
vgPopupAreaActions = (ViewGroup) vgPopupWindow.findViewById(R.id.popup_area_actions);
vgPopupTabs = (LinearLayout) vgPopupWindow.findViewById(R.id.popup_tabs);
vgPopupHeader = (LinearLayout) vgPopupWindow.findViewById(R.id.popup_main_header);
windowManager.addView(vgPopupWindow, params);
Run Code Online (Sandbox Code Playgroud)
因为我不确定WindowManager是否真的是正确的方式,我也尝试对以下风格的活动做同样的事情
<style name="PopupWindow" parent="CustomTheme">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">false</item>
<item name="android:windowIsTranslucent">true</item>
Run Code Online (Sandbox Code Playgroud)
它的外观现在就像WindowManager版本一样,但有一个问题:我无法访问它下面的应用程序窗口,因为窗口的半透明部分看起来很完美,但阻止任何点击事件到下面的窗口,这样我就可以不滚动它或做任何事情.就像在any.do中我只想要显示那个窗口,但是当弹出窗口打开时不阻止任何可能在下面的窗口上工作.
编辑:我想看到底部的弹出窗口,覆盖30%的窗口,但能够同时滚动它下面的窗口(并在其上执行点击事件).
所以我的问题是:
我使用eclipse 跟随了这个spring-mvc-tutorial,但是在我调用Maven / Update Projects之后,我的WEB-INF / lib目录仍然为空。
这是我的项目浏览器的外观:
我也没有在我的Deployment Assembly设置中看到任何错误:
这是我使用的pom.xml文件:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>CrunchifySpringMVCTutorial</groupId>
<artifactId>CrunchifySpringMVCTutorial</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>4.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>4.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins> …Run Code Online (Sandbox Code Playgroud) 我用ViewPager写了一个FragmentActivity,我不想使用操作栏作为标签(因为我不希望标签位于菜单上)而且也不是PagerTabStrip解决方案,因为我无法按照我想要的方式自定义它.
所以我写了一个自己的linearlayout作为标签容器:
<LinearLayout
android:id="@+id/main_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="horizontal" >
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
每个选项卡都有一个View.OnClickListener
OnClickListener onClickListener = new View.OnClickListener() {
@Override
public void onClick(final View view) {
mapTabs.get(lastSelectedTab).setSelected(false);
view.setSelected(true);
Runnable runnable = new Runnable() {
@Override
public void run() {
int index = Integer.parseInt(view.getTag().toString());
FragmentActivity.setTab(index);
lastSelectedTab = index;
}
};
handler.post(runnable);
}
};
}
public static void setTab(int index) {
FragmentActivity.viewPager.setCurrentItem(index, true); // true or false does not make any difference
}
Run Code Online (Sandbox Code Playgroud)
这是我编写的方法将单个选项卡添加到选项卡容器(main_tabs):
private void addTab(LayoutInflater inflater, ViewGroup tabs, int imageId, View.OnClickListener onClickListener) …Run Code Online (Sandbox Code Playgroud)