一、交互代码笔记:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
private
LoginFragmentListener mListener;
@Override
public
void
onAttach(Activity activity)
{
super
.onAttach(activity);
try
{
mListener = (LoginFragmentListener) activity;
}
catch
(ClassCastException e)
{
// throw new ClassCastException(activity.toString() + "must implement LoginFragmentListener");
Log.e(
"接口实现异常"
, activity.toString() +
"未实现LoginFragmentListener接口!"
);
}
}
// 监听登录验证结果的接口
public
interface
LoginFragmentListener
{
// 登录完毕
public
void
OnLoginComplete(String result);
// 登录失败
public
void
OnLoginFailed(String result);
// 退出成功
public
void
OnLoginOutFailed(String mSessionId);
// 退出失败
public
void
OnLoginOutComplete(String result);
}
|
二、重写finish退出最后一个fragment
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
/**
* 重写finish,当fragment栈中只剩最后一个fragment时才finish
*/
@Override
public
void
finish()
{
if
(getSupportFragmentManager().getBackStackEntryCount() ==
0
)
{
super
.finish();
}
else
{
getSupportFragmentManager().popBackStack();
}
}
|
本文转自 glblong 51CTO博客,原文链接:http://blog.51cto.com/glblong/1322346,如需转载请自行联系原作者