小编sar*_*abu的帖子

如何从活动中分段

我正在使用ActionBarSherlock,我无法前往延伸SherlockFragment活动的课程

我需要从Activity转移到片段类

这是我的Activity类

Intent notificationIntent = new Intent(context,MessagesFragment.class);
Run Code Online (Sandbox Code Playgroud)

Fragment类就像

public class MessagesFragment extends SherlockFragment implements
    OnItemClickListener {

// Layout parameters declaration
private PullToRefreshListView lv_messages;
private ImageView iv_no_data;
private LinearLayout ll_bg;

public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    getSherlockActivity().getSupportActionBar().setDisplayOptions(
            ActionBar.DISPLAY_SHOW_CUSTOM);
    getSherlockActivity().getSupportActionBar().setDisplayHomeAsUpEnabled(
            true);
    getSherlockActivity().getSupportActionBar().setHomeButtonEnabled(true);
    getSherlockActivity().getSupportActionBar().setDisplayShowHomeEnabled(
            true);
    getSherlockActivity().getSupportActionBar().setCustomView(
            R.layout.header);
    getSherlockActivity().getSupportActionBar().setBackgroundDrawable(
            new ColorDrawable(Color.parseColor("#009fe3")));
    TextView txt = (TextView) getActivity().findViewById(
            R.id.tv_title_header);
    Typeface font = Typeface.createFromAsset(getActivity().getAssets(),
            "georgia.ttf");
    txt.setText("MESSAGES");
    txt.setTypeface(font);
    return inflater.inflate(R.layout.listview_refreshable, null);
}

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setHasOptionsMenu(true);
}
.
.
. …
Run Code Online (Sandbox Code Playgroud)

android android-fragments android-activity actionbarsherlock

6
推荐指数
1
解决办法
4万
查看次数

使用xmpp时,避免在android中"接受未知证书"警告

我正在尝试搜索XMPP.我从这里得到了代码.它工作正常,我能够连接到服务器.但它显示这样的警报窗口

连接警告

如果我点击"始终"或"一次"它接受,我能够显示联系人和聊天消息....

有没有办法停止此警报,我可以直接连接到服务器吗?

ssl android

3
推荐指数
1
解决办法
2037
查看次数

如何刷新片段中的Action Bar菜单

我正在使用onCreateOptionsMenu在片段中显示操作栏Sherlock菜单.我有一个要求,如果列表为null,则使菜单被禁用,如果存在,则启用菜单中的一些选项并进行更改.这是我的代码

public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    if ((list != null && list.size() > 0)
            || (response != null && response.messageInfo != null && response.messageInfo
                    .size() > 0)) {
        SubMenu submenus = menu.addSubMenu("");
        submenus.add(1, 1, 1, "Send New Message");
        submenus.add(1, 2, 2, "Filter by Category");
        MenuItem subitem = submenus.getItem();
        subitem.setIcon(R.drawable.img_sorting);
        subitem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    } else {
        menu.add(1, 10, 10, "NOT Clickable").setIcon(R.drawable.img_hide)
                .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    }
}
Run Code Online (Sandbox Code Playgroud)

因此,当它第一次加载时,即使列表仍处于禁用模式,它也处于禁用状态,直到我刷新它不会改变其属性.

android actionbarsherlock android-actionbar

1
推荐指数
1
解决办法
6270
查看次数