小编add*_*123的帖子

如何在片段中实现onBackPressed()和意图?

我知道onBackPressed()是一个活动中的方法但是,我想在片段中使用这些功能,这样当按下后退按钮时,它会通过Intent重定向到另一个活动.这有什么解决方案吗?

public class News_Events_fragment extends Fragment {
ProgressDialog pd;
ListView lv1;
SharedPreferences sharedPreferences = null;
int NotiCount;
TextView txt_title, txt_msg, textView;
Context context;
Intent intent ;
ArrayList<SliderMsgTitleModel> CurrentOfficersPastList;
NewsActivityAdapter pastAdapter;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {

    context = (Context) getActivity();

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

    new AsyncTask<Void, Void, ArrayList<SliderMsgTitleModel>>() {

        protected void onPreExecute() {
            pd = new ProgressDialog(getActivity());
            pd.setCancelable(true);
            pd.setTitle("UPOA");
            pd.setMessage("Please wait,loading the data...");
            pd.show();
        }

        @Override
        protected ArrayList<SliderMsgTitleModel> doInBackground(
                Void... params) {
            System.out.println("In Background"); …
Run Code Online (Sandbox Code Playgroud)

android android-intent android-fragments

9
推荐指数
3
解决办法
4万
查看次数

如何在ImageViews中加载多个图像(parse.com)

我在parse.com上将5张图片保存到了我的班级.我可以在imageView中基于objectid下载一个图像.我需要将所有5张图像下载到我的5张ImageViews中.我怎样才能做到这一点.任何帮助,将不胜感激.谢谢

ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("Footer");
            // Locate the objectId from the class
    query.getInBackground("tNp607WyQD", new GetCallback<ParseObject>() {
                public void done(ParseObject object,ParseException e) {
                    // TODO Auto-generated method stub
                    // Locate the column named "ImageName" and set
                    // the string
                    ParseFile fileObject = (ParseFile) object.get("imageFile");
                    fileObject.getDataInBackground(new GetDataCallback() {
                                public void done(byte[] data,ParseException e) {
                                    if (e == null) {
                                        Log.d("test","We've got data in data.");
                                        // Decode the Byte[] into
                                        // Bitmap
                                        Bitmap bmp = BitmapFactory.decodeByteArray(data, 0,data.length);
                                        // Get the ImageView from …
Run Code Online (Sandbox Code Playgroud)

android parse-platform

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

ViewHolder在偶数和奇数位置充气布局

我需要使用ViewHolder基于listview项目的偶数和奇数位置来扩展两个布局.在偶数位置,我需要不同的布局,在奇数位置,另一个具有相同的元素但布局不同.我实现了它,然而,它给了我在不同位置的随机布局,而不管它们的位置如何.需要做些什么来解决它.谢谢.

public SimpleAdapter(ArrayList<WishListData> wishDataList, Context context,
        ListView swipelistview) {
    super(context, android.R.layout.simple_list_item_1, wishDataList);
    notifyDataSetChanged();
    SimpleAdapter.wishListData = wishDataList;
    this.swipelistview = swipelistview;

    mPreferences = new Preferences(context);
    SCREEN_WIDTH = mPreferences.getScreenWidth();
    SCREEN_HEIGHT = mPreferences.getScreenHeight();
    mFunctions = new UserFunctions();
    this.context = context;
    imageloader1 = new ImageLoader1(context);
    userImageLoader = new UserImageLoader(context); 

}

@Override
public View getView(final int position, View convertView, ViewGroup parent) {

    ViewHolder viewHolder = null;
    View row = convertView;
    if (row == null) {
        LayoutInflater inflater = ((Activity) context).getLayoutInflater();
        System.out.println("position "+ position);
        if ((position % …
Run Code Online (Sandbox Code Playgroud)

android android-listview android-viewholder

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