小编Ana*_*kez的帖子

如何将自定义视图添加到布局?

我有一个GraphicsView从类扩展的View类,我想将这个GraphicsView类添加到我的项目的主布局中.我怎样才能做到这一点?

static public class GraphicsView extends View {
        public GraphicsView(Context context) {
        super(context);
        }
        @Override
        protected void onDraw(Canvas canvas) {
        // Drawing commands go here
            Path rect = new  Path();
            rect.addRect(100, 100, 250, 50, Direction.CW);
            Paint cPaint = new Paint();
            cPaint.setColor(Color.LTGRAY); 
            canvas.drawPath(rect, cPaint);
        }
    }
Run Code Online (Sandbox Code Playgroud)

和我的main.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/linnnnlayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello" />

    <TextView 
        android:id="@+id/Customfont"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello" />

     <View 
         android:id="@+id/view"
          android:layout_width="fill_parent"
        android:layout_height="wrap_content"/>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

android android-layout android-view

19
推荐指数
5
解决办法
4万
查看次数

如何使用Google图表API

我使用的是谷歌的图表API在

我如何在Android应用程序中使用此图表?

这是我的代码

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

       String url =  "http://chart.apis.google.com/chart?cht=p3&chs=500x200&chd=e:TNTNTNGa&chts=000000,16&chtt=A+Better+Web&chl=Hello|Hi|anas|Explorer&chco=FF5533,237745,9011D3,335423&chdl=Apple|Mozilla|Google|Microsoft";
        WebView mCharView = (WebView) findViewById(R.id.char_view);
        mCharView.loadUrl(url);
    }
Run Code Online (Sandbox Code Playgroud)

和XML

<?xml version="1.0" encoding="utf-8"?>


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

<WebView android:id="@+id/char_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:visibility="visible"/>


    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello" />

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

android google-api

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

在android中使用"/ proc/mounts"是否有任何限制

我的设备有外部存储(SD卡)和内部数据存储问题.与三星S3设备一样,SD卡和内部数据存储有两种外部存储.该Environment.getExternalStorageDirectory()API没有得到这两个,我在网上搜索和源泉,我可以阅读/proc/mounts类似的问题

如何获取Android设备的所有挂载点信息?

我的问题是,我可以依赖/proc/mounts所有设备和操作系统上的文件系统,还是有任何限制?有没有关于这个文件系统的好文档?

谢谢你的帮助.

filesystems storage android

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

使用android中的文件描述符阅读联系人的信息

我在从联系人列表中获取联系人时遇到问题.我正在使用此代码:

final Cursor Contact = cResolver.query(ContactsContract.Contacts.CONTENT_URI, null,
                ContactsContract.Contacts._ID +" = " + Contact_ID, null,null);
        Contact.moveToFirst();
        String lookupKey = Contact.getString(Contact
                .getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY));

        Uri uri = Uri.withAppendedPath(
                ContactsContract.Contacts.CONTENT_VCARD_URI, lookupKey);

        AssetFileDescriptor fd = null;
        FileInputStream fis = null;

        fd = cResolver.openAssetFileDescriptor(uri, "_ID");
        fis = fd.createInputStream();
        byte[] buf = new byte[(int) fd.getDeclaredLength()];
        fis.read(buf);
        String vcardstring = new String(buf);
Run Code Online (Sandbox Code Playgroud)

但是我得到了Exception:

java.io.IOException: read failed: EINVAL (Invalid argument)
libcore.io.IoBridge.read(IoBridge.java:432)
Run Code Online (Sandbox Code Playgroud)

谁能帮我这个?

android file-descriptor contacts

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

如何将颜色从十六进制转换为RGB

我在String.xml文件中有颜色,这样 <color name="ItemColor1">#ffff992b</color> 我怎么能转换为四个变量

float Red;
float Green;
float Blue;
float Alfa;
Run Code Online (Sandbox Code Playgroud)

在Java代码?任何人都可以帮忙

android colors

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

如何获取草稿短信的地址

我无法获得短信草案的地址,它总是null使用以下代码给我

 public static final Uri SMS_PROVIDER = Uri.parse("content://sms");     
     Cursor oCursorSMS = mContext.getContentResolver().query(SMS_PROVIDER, null,null,null, null);                                                           
oCursorSMS.moveToFirst();                                     
        final String[] columns = oCursorSMS.getColumnNames();                           
        for (int i = 0; i < columns.length; i++) {
            String ss = cursor.getString(i);
            } 
Run Code Online (Sandbox Code Playgroud)

当我阅读短信草案时,地址栏返回null我已经搜索了很多,有很多关于这个问题的问题,但没有人回答.谁能帮我这个

sms android

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

如何在android中将时间戳转换为日期?

我有一个时间戳在我的XML中,我放入我的数据库.

时间戳采用自1970年以来经过的秒数的格式.我想将其转换为日期对象.

我该怎么办呢?

先感谢您.

java android timestamp

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

如何为ListView制作滚动事件

我想在ListView中为滚动创建一个事件.

我发现了一些有效的东西,但它只在使用滚动条时触发事件.它不响应鼠标滚轮或箭头滚动.

private const int WM_HSCROLL = 0x114;
private const int WM_VSCROLL = 0x115;

public event EventHandler Scroll;

protected void OnScroll()
{
   if (this.Scroll != null)
      this.Scroll(this, EventArgs.Empty);
}

protected override void WndProc(ref System.Windows.Forms.Message m)
{
   base.WndProc(ref m);
   if (m.Msg == WM_HSCROLL || m.Msg == WM_VSCROLL )
      this.OnScroll();
}
Run Code Online (Sandbox Code Playgroud)

为鼠标滚轮和键盘上/下按钮触发滚动事件需要什么常量?

c# listview winforms

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