小编Yev*_*eni的帖子

SwipeRefreshLayout只能托管一个直接子项

我在listView中添加了"pull to refresh",我还想在列表为空时添加一个空视图 - 现在我收到了这个错误.我怎样才能做到这一点?如果我将一个视图定位在swipeRefresh之外,然后将其添加为emptyView它将起作用.那么我如何使用外部xml文件呢?

xml代码:

        <android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/swipeRefreshLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true" >


        <ListView
            android:id="@android:id/list"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:clipToPadding="false"
            android:paddingBottom="@dimen/inbox_vertical_margin" ></ListView>


</android.support.v4.widget.SwipeRefreshLayout>
Run Code Online (Sandbox Code Playgroud)

onCreateView:

View rootView = inflater.inflate(R.layout.fragment_inbox, container,
        false);

View empty = inflater.inflate(R.layout.empty_message_list, container,
        false);
ListView mListView = (ListView) rootView
        .findViewById(android.R.id.list);
((ViewGroup) mListView.getParent()).addView(empty);
TextView textViewToChange = (TextView) empty
        .findViewById(R.id.welcomeMessage);

textViewToChange.setText("YO "
        + ParseUser.getCurrentUser().getString(
                ParseConstants.KEY_PRESENTING_USERNAME)
        + "!  bad news.. :(");
mListView.setEmptyView(empty);

mSwipeRefreshLayout = (SwipeRefreshLayout) rootView
        .findViewById(R.id.swipeRefreshLayout);
mSwipeRefreshLayout.setOnRefreshListener(mOnRefreshListener);
mSwipeRefreshLayout.setColorScheme(R.color.swipeRefresh1,
        R.color.swipeRefresh2, R.color.swipeRefresh3,
        R.color.swipeRefresh4);

return rootView;
Run Code Online (Sandbox Code Playgroud)

xml android setcontentview

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

如何仅使用静态单元格创建集合视图?

我想添加一个包含7个静态单元格的垂直集合视图.我知道如何动态地做,但我没有理由这样做.

我必须使用cellForRow方法吗?我添加了一个集合视图到我的viewController,并添加了4个单元格,将委托从collectionView连接到vc(使用storyBoard),但是当我运行它时,它显示了一个空的collectionView.

我确实设置了numberOfSections返回1而numberOfCellsInSection返回7.所以我错过了什么?或者我是否必须遵守DataSource协议并实现cellForRow方法?(在TableView中,我可以在使用静态单元格时跳过cellForRow).

谢谢您的帮助.

objective-c ios uicollectionview

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

使用毕加索获取用户的Facebook个人资料照片

我正在使用Parse作为后端,我试图获取用户个人资料图片并显示它.我不想使用ProfilePictureView,因为我使用gridview也显示其他imageViews.如你所见,我也在使用gravater api.

所以问题是:它不会显示个人资料图片,只显示占位符图片(gravatar工作正常并显示),我做错了什么?

   ParseUser user = mUsers.get(position);
            String email;
            if (user.getEmail() == null) { // this is how i check if its a facebook
                                            // user

                ParseUser currentUser = user;
                if (currentUser.get(ParseConstants.KEY_FACEBOOK_DETAILS) != null) {
                    JSONObject userProfile = currentUser
                            .getJSONObject(ParseConstants.KEY_FACEBOOK_DETAILS);
                    try {
                        if (userProfile.getString("facebookId") != null) {
                            String facebookId = userProfile.get("facebookId")
                                    .toString();
                            String facebookName = userProfile.getString("name");
                            holder.nameLabel.setText(facebookName);
                            // holder.userImageView.setProfileId(facebookId);
                            String facebookProfilePicUrl = "http://graph.facebook.com/"
                                    + facebookId + "/picture";

                            Picasso.with(mContext).load(facebookProfilePicUrl)
                                    .placeholder(R.drawable.avatar_empty)
                                    .into(holder.userImageView);
                        }
                    } catch (JSONException e) {
                        // TODO Auto-generated catch …
Run Code Online (Sandbox Code Playgroud)

android gravatar facebook-graph-api picasso

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