コード例 #1
0
 public override void bindView(android.view.View view, android.content.Context context
                               , android.database.Cursor cursor)
 {
     android.widget.CheckedTextView text = (android.widget.CheckedTextView)view.findViewById
                                               ([email protected]);
     text.setText(java.lang.CharSequenceProxy.Wrap(cursor.getString(this.mLabelIndex))
                  );
     listView.setItemChecked(cursor.getPosition(), cursor.getInt(this.mIsCheckedIndex)
                             == 1);
 }
コード例 #2
0
        private android.graphics.drawable.Drawable getIcon2(android.database.Cursor cursor
                                                            )
        {
            if (mIconName2Col == INVALID_INDEX)
            {
                return(null);
            }
            string value = cursor.getString(mIconName2Col);

            return(getDrawableFromResourceValue(value));
        }
コード例 #3
0
        public override void onActivityResult(int requestCode, int resultCode, Intent data)
        {
            base.onActivityResult(requestCode, resultCode, data);

            if (requestCode == REQUEST_CODE_ACTION_PICK)
            {
                if (data != null)
                {
                    Uri uri = data.Data;
                    System.IO.Stream @is = null;
                    try
                    {
                        @is = ContentResolver.openInputStream(uri);
                    }
                    catch (FileNotFoundException e)
                    {
                        Console.WriteLine(e.ToString());
                        Console.Write(e.StackTrace);
                        return;
                    }

                    try
                    {
                        BitmapFactory.Options opts = new BitmapFactory.Options();
                        opts.inJustDecodeBounds = false;
                        opts.inSampleSize       = 1;
                        opts.inPreferredConfig  = Bitmap.Config.RGB_565;
                        Bitmap bm = BitmapFactory.decodeStream(@is, null, opts);
                        mImageView.ImageBitmap = bm;
                    }
                    catch (System.OutOfMemoryException e)
                    {
                        Console.WriteLine(e.ToString());
                        Console.Write(e.StackTrace);
                        return;
                    }

                    ContentResolver cr = ContentResolver;
                    Cursor          c  = cr.query(uri, new string[] { MediaStore.Images.Media.DATA }, null, null, null);
                    if (c == null || c.Count == 0)
                    {
                        return;
                    }
                    c.moveToFirst();
                    int    columnIndex = c.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
                    string text        = c.getString(columnIndex);
                    mTextView.Text = text;
                }
            }
        }
コード例 #4
0
        private android.graphics.drawable.Drawable getIcon1(android.database.Cursor cursor
                                                            )
        {
            if (mIconName1Col == INVALID_INDEX)
            {
                return(null);
            }
            string value = cursor.getString(mIconName1Col);

            android.graphics.drawable.Drawable drawable = getDrawableFromResourceValue(value);
            if (drawable != null)
            {
                return(drawable);
            }
            return(getDefaultIcon1(cursor));
        }
コード例 #5
0
        public override void bindView(android.view.View view, android.content.Context context
                                      , android.database.Cursor cursor)
        {
            android.widget.SimpleCursorAdapter.ViewBinder binder = mViewBinder;
            int count = mTo.Length;

            int[] from = mFrom;
            int[] to   = mTo;
            {
                for (int i = 0; i < count; i++)
                {
                    android.view.View v = view.findViewById(to[i]);
                    if (v != null)
                    {
                        bool bound = false;
                        if (binder != null)
                        {
                            bound = binder.setViewValue(v, cursor, from[i]);
                        }
                        if (!bound)
                        {
                            string text = cursor.getString(from[i]);
                            if (text == null)
                            {
                                text = string.Empty;
                            }
                            if (v is android.widget.TextView)
                            {
                                setViewText((android.widget.TextView)v, text);
                            }
                            else
                            {
                                if (v is android.widget.ImageView)
                                {
                                    setViewImage((android.widget.ImageView)v, text);
                                }
                                else
                                {
                                    throw new System.InvalidOperationException(v.GetType().FullName + " is not a " +
                                                                               " view that can be bounds by this SimpleCursorAdapter");
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #6
0
 public override java.lang.CharSequence convertToString(android.database.Cursor cursor
                                                        )
 {
     if (mCursorToStringConverter != null)
     {
         return(mCursorToStringConverter.convertToString(cursor));
     }
     else
     {
         if (mStringConversionColumn > -1)
         {
             return(java.lang.CharSequenceProxy.Wrap(cursor.getString(mStringConversionColumn)
                                                     ));
         }
     }
     return(base.convertToString(cursor));
 }
コード例 #7
0
 private static string getStringOrNull(android.database.Cursor cursor, int col)
 {
     if (col == INVALID_INDEX)
     {
         return(null);
     }
     try
     {
         return(cursor.getString(col));
     }
     catch (System.Exception e)
     {
         android.util.Log.e(LOG_TAG, "unexpected error retrieving valid column from cursor, "
                            + "did the remote process die?", e);
         return(null);
     }
 }
コード例 #8
0
 private void bindView(android.view.View view, android.content.Context context, android.database.Cursor
                       cursor, int[] from, int[] to)
 {
     android.widget.SimpleCursorTreeAdapter.ViewBinder binder = mViewBinder;
     {
         for (int i = 0; i < to.Length; i++)
         {
             android.view.View v = view.findViewById(to[i]);
             if (v != null)
             {
                 bool bound = false;
                 if (binder != null)
                 {
                     bound = binder.setViewValue(v, cursor, from[i]);
                 }
                 if (!bound)
                 {
                     string text = cursor.getString(from[i]);
                     if (text == null)
                     {
                         text = string.Empty;
                     }
                     if (v is android.widget.TextView)
                     {
                         setViewText((android.widget.TextView)v, text);
                     }
                     else
                     {
                         if (v is android.widget.ImageView)
                         {
                             setViewImage((android.widget.ImageView)v, text);
                         }
                         else
                         {
                             throw new System.InvalidOperationException("SimpleCursorTreeAdapter can bind values"
                                                                        + " only to TextView and ImageView!");
                         }
                     }
                 }
             }
         }
     }
 }