package com.bwie.test;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

public class Annulus extends View {

    private Context context;
    private Paint paint;

    public Annulus(Context context) {
        this(context, null);
    }

    public Annulus(Context context, AttributeSet attrs) {
        super(context, attrs);
        this.context = context;
        this.paint = new Paint();
        this.paint.setAntiAlias(true);
        this.paint.setStyle(Paint.Style.STROKE);

    }

    @Override
    public void onDraw(Canvas canvas) {

        int center = getWidth() / 2;
        int cennCricle = dip2px(context, Float.valueOf(MainActivity.mRadius));// 设置内圆半径
        int cricleWith = dip2px(context, Float.valueOf(MainActivity.mWidth));// 设置圆环宽度

        // 绘制内圆
        this.paint.setARGB(155, 167, 190, 206);
        this.paint.setStrokeWidth(2);
        canvas.drawCircle(center, center, cennCricle, this.paint);
        // 绘制圆环
        this.paint.setARGB(255, 212, 225, 233);
        this.paint.setStrokeWidth(cricleWith);
        this.paint.setColor(Color.parseColor(MainActivity.hcolor));
        canvas.drawCircle(center, center, cennCricle + cricleWith / 2,
                this.paint);
        // 绘制外圆
        this.paint.setARGB(155, 167, 190, 206);
        this.paint.setStrokeWidth(2);
        canvas.drawCircle(center, center, cennCricle + cricleWith, this.paint);

        super.onDraw(canvas);

    }

    private static int dip2px(Context context, float dpValue) {

        final float scale = context.getResources().getDisplayMetrics().density;
        return (int) (dpValue * scale + 0.5f);
    }

}




***************************************************************************************************************************************************

package com.bwie.test;

import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

import org.xmlpull.v1.XmlPullParser;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.app.Activity;
import android.util.Xml;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class MainActivity extends Activity {

    private Annulus an;
    public static String mRadius = "100";
    public static String mWidth = "10";
    public static String hcolor = "#ff0000";
    private ListView listView;
    private URL uu;
    List<StudentBean>al=new ArrayList<StudentBean>();
    private HttpURLConnection hc;
    private StudentBean rr;
    
    private Handler handler=new Handler(){
        public void handleMessage(android.os.Message msg) {
            listView.setAdapter(new Myadapter());
        };
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        // 获得控件
        Initview();
        // 获得数据
        Initdata();
    }

    /**
     * 数据
     */
    private void Initdata() {
        new Thread() {
            public void run() {
                getStr();
                
            };
        }.start();
    }
    
    //适配器
    class Myadapter extends BaseAdapter{

        @Override
        public int getCount() {
            // TODO Auto-generated method stub
            return 20;
        }

        @Override
        public Object getItem(int position) {
            // TODO Auto-generated method stub
            return null;
        }

        @Override
        public long getItemId(int position) {
            // TODO Auto-generated method stub
            return 0;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            if (convertView==null) {
                convertView=View.inflate(getApplicationContext(), R.layout.item, null);
            }
            TextView t1=(TextView)findViewById(R.id.textView1);
            TextView t2=(TextView)findViewById(R.id.textView2);
            TextView t3=(TextView)findViewById(R.id.textView3);
            int i=1;
            i++;
            t1.setText("zx"+i);
            t2.setText("hd");
            t3.setText("bw");
            return convertView;
        }
        
    }

    // httputlconnection请求
    protected void getStr() {
        try {
            uu = new URL(
                    "http://172.17.29.120/localuser/loupengfei/kaoshi/student.xml");
            hc = (HttpURLConnection) uu.openConnection();
            hc.setRequestMethod("GET");
            hc.setConnectTimeout(5000);
            int code = hc.getResponseCode();
            if (code == 200) {
                // xml解析
                Xmlparse();
            }
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    // 解析
    private void Xmlparse() throws Exception {
        InputStream inputStream = hc.getInputStream();
        XmlPullParser xp = Xml.newPullParser();
        xp.setInput(inputStream, "utf-8");
        int eventType = xp.getEventType();
        String stagname = null;
        while (eventType != XmlPullParser.END_DOCUMENT) {
        switch (eventType) {
        case XmlPullParser.START_DOCUMENT:


        break;


        case XmlPullParser.START_TAG:
        stagname = xp.getName();
        if ("student".equals(stagname)) {
        rr = new StudentBean();
        }
        break;
        case XmlPullParser.TEXT:
        if ("name".equals(stagname)) {
        rr.name = xp.getText().trim();
        } else if ("address".equals(stagname)) {
        rr.address = xp.getText().trim();
        } else if ("school".equals(stagname)) {
        rr.school = xp.getText().trim();
        }
        break;
        case XmlPullParser.END_TAG:
        stagname = xp.getName();
        if ("student".equals(stagname)) {
        al.add(rr);
        Message msg = Message.obtain();
        msg.obj = al;
        handler.sendMessage(msg);
        rr = null;
        }
        stagname = "";


        break;
        case XmlPullParser.END_DOCUMENT:


        break;


        }
        eventType = xp.next();
        }
    }

    private void Initview() {
        an = (Annulus) findViewById(R.id.ann);
        listView = (ListView) findViewById(R.id.listview);
    }
}



1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。、可私 6信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 、可私信6博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 、可私信6博主看论文后选择购买源代码。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值