android Adapter空指针问题 求大神看看 解决不了

是这样的。我是在做一个相当于一个手机卫士,里面有通讯录和黑名单两个功能。这个代码是我做的黑名单里的。图片说明 想实现的功能是点黑名单按钮,可以出现这个黑名单的Activity。通讯录做了一个Listview,点通讯录按钮,可以导入系统通讯录,然后设置点击监听,长按item可以发短信,点击可以打电话。

现在的问题是,无论是通讯录还是黑名单,一点按钮就报错,报错的内容就是空指针。不知道怎么觉得。哭唧唧。

这个是代码。无论尝试什么方法,都报错空指针。
package com.jinwen.pengu.communication;

import android.app.Activity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.List;

public class Stop extends Activity {
private ListView iv_main;
private BlackNumberAdapter adapter;
private BlackNumberDao dao;
private List data;

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    iv_main = (ListView) findViewById(R.id.iv_main);
    adapter = new BlackNumberAdapter();
    dao = new BlackNumberDao(this);
    data = dao.getAll();
    iv_main.setAdapter(adapter);
}



public void add(View v){

}
class BlackNumberAdapter extends BaseAdapter{

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView ==null){
            convertView = View.inflate(Stop.this,android.R.layout.simple_list_item_1,null);
        }
        BlackNumber blackNumber = data.get(position);
        TextView textView = (TextView) convertView.findViewById(android.R.id.text1);
        textView.setText(blackNumber.getNumber());
        return convertView;
    }

}

}

错误: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference
at com.jinwen.pengu.communication.Stop.onCreate(Stop.java:31)

9个回答

初始化适配器的时候,数据源data是空的,
adapter = new BlackNumberAdapter();
要放在
dao = new BlackNumberDao(this);
data = dao.getAll();
的下面

convertView = View.inflate(Stop.this,android.R.layout.simple_list_item_1,null); 这一行有问题,改为
convertView = Layoutinflater.form(context).inflate(Stop.this,android.R.layout.simple_list_item_1,null);

qq_39205783
qq_39205783 大神你好!我不懂你这个代码的意思,但是我复制了进去 发现也是报错的,而且我不知道怎么解决。我才刚学,不好意思啊。
2 年多之前 回复

convertView = View.inflate(Stop.this,android.R.layout.simple_list_item_1,null);
我也认为是这一行的错误

HuoHao_Blogs
huohao-nicole 回复qq_39205783: convertView = Layoutinflater.form(context).inflate(布局文件资源,parent,false);
2 年多之前 回复
qq_39205783
qq_39205783 请问是哪里错了呢,我才刚学,有点不明白
2 年多之前 回复

listview在设置adapter的时候出现了空指针,你看看你的listview是不是没有获取到,是不是空。

即iv_main = (ListView) findViewById(R.id.iv_main);这句话以后即iv_main是不是空。

看看布局文件有没有写错,activity_main里面有没有id为iv_main的listview控件

zengxianzi
昭杏之念 回复qq_39205783: 那你的 setContentView(R.layout.activity_main);就应该改成 setContentView(R.layout.activity_stop);啊
2 年多之前 回复
qq_39205783
qq_39205783 我写在了activity_stop里 没有写在activity_main里,我想做的这个相当于一个手机卫士,黑名单stop是我想实现的其中一个功能。
2 年多之前 回复

是这样的。我是在做一个相当于一个手机卫士,里面有通讯录和黑名单两个功能。这个代码是我做的黑名单里的。图片说明 想实现的功能是点黑名单按钮,可以出现这个黑名单的Activity。通讯录做了一个Listview,点通讯录按钮,可以导入系统通讯录,然后设置点击监听,长按item可以发短信,点击可以打电话。

现在的问题是,无论是通讯录还是黑名单,一点按钮就报错,报错的内容就是空指针。不知道怎么觉得。哭唧唧。

你findvie完了之后打印下iv_main这个变量是不是null

断点调试,是开发必要技能,在报空地方打断点 ,定位问题,在仔细招待码的问题。

楼上正解,是data的问题,

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
Struts2空指针问题,求大神帮忙看看
jsp页面:rn<%rnMap req=(Map)ActionContext.getContext().get("request");rnList list1=(List)req.get("list1");rnif(list1==null)rnreq.put("list",list);rn//if(list==null)rn//req.put("list",list1);rnelsernreq.put("list",list1);rn%>rn这里的list1是搜索功能代替原来的list实现显示搜索的功能rnrnserachAction:rnrnpublic class SearchAction extends ActionSupport rn private String searchText;rnrn public String getSearchText() rn return searchText;rn rnrn public void setSearchText(String searchText) rn this.searchText = searchText;rn rn rn public String execute() throws Exception rn DB db=new DB();rn List list=db.searchLyInfo(searchText);rn Map request=(Map)ActionContext.getContext().get("request");rn request.put("list1", list);rn return "success";rn rn rn rn rn rn rnrnloginAction:rnpackage com.action;rnrnimport java.util.Map;rnimport com.DB;rnimport com.User;rnimport com.opensymphony.xwork2.ActionContext;rnimport com.opensymphony.xwork2.ActionSupport;rnpublic class LoginAction extends ActionSupportrn private String username;rn private String password;rn public String getUsername() rn return username;rn rn public void setUsername(String username) rn this.username = username;rn rn public String getPassword() rn return password;rn rn public void setPassword(String password) rn this.password = password;rn rn rn public String execute() throws Exception rn User user=new com.DB().check(username, password);rn // int userid=new DB().check(username,password);rn if(user!=null)rn Map session=ActionContext.getContext().getSession();rn session.put("user", user);rn return SUCCESS;rn elsern addFieldError("username","用户名或密码错误!");rn return ERROR;rn rnrn一个留言板项目,当我登陆进去留言板的时候,搜索是没有问题的(见上面的searchAction)rn但是当我不登陆直接进入留言板显示页面就会出错:rnrnrniption The server encountered an internal error () that prevented it from fulfilling this request.rnrnexception rnrnorg.apache.jasper.JasperException: An exception occurred processing JSP page /ceshi.jsp at line 12rnrn9: //com.DB db=new com.DB();rn10: //com.User user=(com.User)ActionContext.getContext().getSession().get("user");rn11: //List list1=(List)ActionContext.getContext().getSession().get("list1");rn12: List list1=(List)req.get("list1");rn13: if(list1==null)rn14: req.put("list",list);rn15: //if(list==null)rnrn求大神帮助
求大神解答,空指针的问题
代码是用jsch连接ssh。rn这样写没问题,可以加载远程目录下的文件rn[code=java]rnpublic class SftpTest rn private String host;rn private String username;rn private String password;rn private int port = 22;rn private ChannelSftp channelSftp;rn private Session session;rnrn public SftpTest() rn rnrn public SftpTest(String host, String username, String password, int port) rn this.host = host;rn this.username = username;rn this.password = password;rn this.port = port;rn rn /**rn * connect server via sftprn */rn public void connect() rn String localPath = "G:/sftp/";rn String remotePath = "/home/Administrator";rn rn try rnrn JSch jsch = new JSch(); rn session= jsch.getSession(username, host, port);rn System.out.println("Session created.");rn session.setPassword(password);rn Properties sshConfig = new Properties();rn sshConfig.put("StrictHostKeyChecking", "no");rn session.setConfig(sshConfig);rn session.connect();rn System.out.println("Session connected.");rn System.out.println("Opening Channel.");rn ChannelSftp channelSftp = (ChannelSftp) session.openChannel("sftp");rn channelSftp.connect();rn System.out.println("Connected to " + host + ".");rn rn Vector listFiles=channelSftp.ls(remotePath);rn for(int i=0;i
关于adapter报空指针问题
主要是因为声明了变量没有初始化!!!!!
adapter的inflater.inflate报空指针
我按照教程尝试编写自定义Adapter,继承BaseAdapter,在重写getView方法时,使用了rnconvertView = inflater.inflate(R.layout.lv_test_list,null); 然而在运行时就报错了,显示 java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup)' on a null object reference。但是,视频教程就是这么写的~~如下图所示,第70行代码。请问我的问题出在哪里?我该如何修改?rn[img=https://img-bbs.csdn.net/upload/201609/20/1474361648_357886.jpg][/img]rnrn下面是我写的代码:rn [code=java]rnpublic class ListAdapter extends BaseAdapter rnrn private List items;rn LayoutInflater inflater;rn public ListAdapter(Context context,List source)rn items = source;rn inflater.from(context);rn rnrn@Overridern public View getView(int position, View convertView, ViewGroup parent) rn ViewHolder vh;rn if(convertView == null)rn convertView = inflater.inflate(R.layout.lv_test_list,null);rn ImageView img = (ImageView) convertView.findViewById(R.id.img_icon);rn TextView tv_title = (TextView) convertView.findViewById(R.id.tv_title);rn TextView tv_content = (TextView) convertView.findViewById(R.id.tv_content);rn vh = new ViewHolder();rn vh.content = tv_content;rn vh.title = tv_title;rn vh.img = img;rn convertView.setTag(vh);rn rn elsern vh = (ViewHolder) convertView.getTag();rn rn ListAdapterItem item = items.get(position);rn vh.content.setText(item.str_content);rn vh.title.setText(item.str_title);rn vh.img.setImageResource(item.int_img);rn return convertView;rn rnrn class ViewHolder rn public ImageView img;rn public TextView title;rn public TextView content;rn rn[/code]
【求助】android adapter报空指针错误
先贴出源码rnpublic class Main extends ListActivity rn SQLiteDatabase sqLiteDatabase;rn private ArrayList> data;rn @Overridern protected void onCreate(Bundle savedInstanceState) rn super.onCreate(savedInstanceState);rn data = getData();rn MyAdapter adapter = new MyAdapter(this);rn setListAdapter(adapter);rn rnrn public ArrayList> getData()rn sqLiteDatabase = this.openOrCreateDatabase("phoneBook.db", Context.MODE_PRIVATE, null);rn Cursor cursor = sqLiteDatabase.rawQuery("SELECT name,phones FROM phonebook",null);rn ArrayList> list = new ArrayList>();rn Map map = new HashMap();rn int i = 0;rn while(cursor.moveToNext())rn map = new HashMap();rn map.put("name",cursor.getString(0));rn map.put("phone",cursor.getString(1));rn list.add(map);rn i++;rn rn return list;rn rnrn public final class viewContentrn ImageView image;rn TextView name;rn TextView phone;rn Button msg;rn Button dial;rn rnrn public class MyAdapter extends BaseAdapterrn private LayoutInflater inflater;rnrn public MyAdapter(Context context)rn this.inflater = LayoutInflater.from(context);rn rn @Overridern public int getCount() rn return data.size();rn rnrn @Overridern public Object getItem(int position) rn return null;rn rnrn @Overridern public long getItemId(int position) rn return 0;rn rnrn @Overridern public View getView(int position, View convertView, ViewGroup parent) rn viewContent vc = null;rn if(convertView == null)rn vc = new viewContent();rn convertView = inflater.inflate(R.layout.main,null);rn vc.image = (ImageView)findViewById(R.id.image);rn vc.name = (TextView)findViewById(R.id.name);rn vc.phone = (TextView)findViewById(R.id.phone);rn vc.dial = (Button)findViewById(R.id.dial);rn vc.msg = (Button)findViewById(R.id.msg);rn convertView.setTag(vc);rn elsern vc = (viewContent)convertView.getTag();rn rn //vc.image.setBackgroundResource((Integer)data.get(position).get("image"));rn vc.name.setText((String)data.get(position).get("name"));rn vc.phone.setText((String)data.get(position).get("phone"));rn return convertView;rn rn rnrnrn[color=#3366FF][size=18px]总是报空指针错误啊,一模拟就停止运行,不知道错在哪了,求助!!!![/size][/color]rnrn[color=#FF0000]java.lang.NullPointerExceptionrn at com.example.qiao_yixuan.sqlitetest.Main$MyAdapter.getView(Main.java:99)rn at android.widget.AbsListView.obtainView(AbsListView.java:2738)rn at android.widget.ListView.makeAndAddView(ListView.java:1811)rn at android.widget.ListView.fillDown(ListView.java:697)rn at android.widget.ListView.fillFromTop(ListView.java:763)rn at android.widget.ListView.layoutChildren(ListView.java:1641)rn at android.widget.AbsListView.onLayout(AbsListView.java:2563)rn at android.view.View.layout(View.java:15762)rn at android.view.ViewGroup.layout(ViewGroup.java:4880)rn at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)rn at android.widget.FrameLayout.onLayout(FrameLayout.java:388)rn at android.view.View.layout(View.java:15762)rn at android.view.ViewGroup.layout(ViewGroup.java:4880)rn at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1677)rn at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1531)rn at android.widget.LinearLayout.onLayout(LinearLayout.java:1440)rn at android.view.View.layout(View.java:15762)rn at android.view.ViewGroup.layout(ViewGroup.java:4880)rn at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)rn at android.widget.FrameLayout.onLayout(FrameLayout.java:388)rn at android.view.View.layout(View.java:15762)rn at android.view.ViewGroup.layout(ViewGroup.java:4880)rn at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2356)rn at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2069)rn at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1254)rn at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6637)rn at android.view.Choreographer$CallbackRecord.run(Choreographer.java:814)rn at android.view.Choreographer.doCallbacks(Choreographer.java:614)rn at android.view.Choreographer.doFrame(Choreographer.java:584)rn at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:800)rn at android.os.Handler.handleCallback(Handler.java:733)rn at android.os.Handler.dispatchMessage(Handler.java:95)rn at android.os.Looper.loop(Looper.java:146)rn at android.app.ActivityThread.main(ActivityThread.java:5602)rn at java.lang.reflect.Method.invokeNative(Native Method)rn at java.lang.reflect.Method.invoke(Method.java:515)rn at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)rn at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)rn at dalvik.system.NativeStart.main(Native Method)[/color]
求大神解决空指针报错!
activity.jsprnrnList beanListResult =(List)request.getAttribute("list");rnIterator iter_beanList = beanListResult.iterator();rnrnServletrnelse if("/background".equals(module_path))/*访问后台管理模块*/rn ActivityDao activityDao=new ActivityDao();rn if("queryList".equals(action))rn List list=activityDao.queryList(req);rn req.setAttribute("activity", list);rn req.getRequestDispatcher("/background/activity.jsp").forward(req,resp); rn rnrnDAOrnpublic List queryList(HttpServletRequest req)rnString sql="select * from company_acitvityenroll";rnList list=DbBuilder.getListBean(sql,Activity.class);rn return list;rnrnrnSEVERE: Servlet.service() for servlet [jsp] in context with path [] threw exception [An exception occurred processing JSP page /background/activity.jsp at line 166rnrn163: rn164: <%rn165: List beanListResult =(List)request.getAttribute("list");rn166: Iterator iter_beanList = beanListResult.iterator();rn167: while (iter_beanList.hasNext()) rn168: Activity activity=iter_beanList.next();rn169: %>rnrnrnStacktrace:] with root causernjava.lang.NullPointerException
遮罩层的弊端(解决不了,求大神)
遮罩层里面的日期如何固定??? 开发工具与关键技术: css、js 作者:邱慧敏 撰写时间:2019.01.18 要制作遮罩层先要给外层设置绝对定位和相对定位 不然会混乱,(绝对定位和相对定位在HTML中有一定的重要作用) 遮罩层里面的日期 和跟着鼠标的滚动而滚动??? 正常情况下 但实际情况 却却却 这样??? 日期用了插件 代码 ...
Android监听器的空指针问题,求大神指教!在线等!谢谢!
package mei.activity02;rnrnimport android.os.Bundle;rnimport android.widget.Button;rnimport android.app.Activity;rnimport android.content.Intent;rnimport android.view.Menu;rnimport android.view.View;rnimport android.view.View.OnClickListener;rnrnrnpublic class Activity02 extends Activity rn private Button myButton = null;rn @Overridern protected void onCreate(Bundle savedInstanceState) rn super.onCreate(savedInstanceState);rn setContentView(R.layout.activity02);rn myButton = (Button)findViewById(R.id.myButton);rn [color=#FF0000]myButton.setOnClickListener(new MyButtonListener());[/color]rn rn rn class MyButtonListener implements OnClickListenerrnrn @Overridern public void onClick(View v) rn // TODO Auto-generated method stubrn Intent intent = new Intent();rn intent.setClass(Activity02.this, OtherActivity.class);rn startActivity(intent);rn rn rn rn rnrn一直提示红色部分空指针!布局文件之类的都检查了,有myButton,OtherActivity也已经注册!不知道为什么,求高手指点!
我要疯了,简单问题解决不了,求大神
android代码[code=java]private class ClickListener implements View.OnClickListenerrn @Overridern public void onClick(View v) rn useridedit = (EditText)findViewById(R.id.userid);rn passedit = (EditText)findViewById(R.id.pass);rn String userid = useridedit.getText().toString();rn String pass = passedit.getText().toString();rn String urlstr = "http://172.18.112.151:8080/chatserver/CheckLogin?userid="+userid+"&pass="+pass;rn try rn URL url = new URL(urlstr);rn HttpURLConnection conn = (HttpURLConnection)url.openConnection();rn Log.i("v", urlstr);rn Toast.makeText(getApplicationContext(), userid+"", 1).show();rn catch (MalformedURLException e) rn e.printStackTrace();rn catch (IOException e) rn e.printStackTrace();rn rn /*if(!userid.equals("") && !pass.equals(""))rn if(v.getId()==login.getId())rn if(new CheckLogin().check(userid, pass))rn rn elsern Toast.makeText(getApplicationContext(), R.string.loginerror, Toast.LENGTH_SHORT).show();rn rn else if(v.getId()==cancel.getId())rn MainActivity.this.finish();rn rn elsern Toast.makeText(getApplicationContext(), R.string.loginvalid, Toast.LENGTH_SHORT).show();rn */rn [/code]rnservlet代码:[code=java]public void doPost(HttpServletRequest request, HttpServletResponse response)rn throws ServletException, IOException rn System.out.println("init");rn String userid = request.getParameter("userid");rn String pass = request.getParameter("pass");rn System.out.println(userid+" "+pass);rn rn[/code]rn问题:为嘛我的servlet里面的System.out.println(userid+" "+pass);什么也没油打印
求大神,求指教,为什么会有空指针
[color=#FF6600]liuyan.jsp页面[/color]rn[color=#FF6600]此页面可以运行,可获取值[/color]rn<% LiuyanOpr po=new LiuyanOpr();rn ArrayList list=po.list();rn if(list!=null)rn for(Liuyan p:list)rn %>rn rn <% %>rnrnrn[color=#FF6600]liuyanxq.jsp页面[/color]rn <%rn String strId=request.getParameter("[color=#FF0000]theid[/color]");rn Liuyan p=null;rn if(strId!=null) rn int id=Integer.parseInt(strId);rnrn LiuyanOpr po=new LiuyanOpr();rn p= po.getLiuyanById(id);rn rn %>rn rn 留言详情 rn rn rn 发帖人:<%=p.getThrname() %>发帖日期: <%=p.getThrtime() %>rn 标题: <%=p.getThrtitle() %>rn 详情: <%=p.getThrcontant() %> rn 回复 rn 所有回复rn rn rn <% rn rn ArrayList list=(ArrayList) session.getAttribute("replaydetail");//从Session中取数据rn if(list!=null) rn for(Liuyan p1:list) rn rn %> rn rn rn 回帖人:<%=p1.getRepname() %>回帖日期:<%=p1.getReptime() %>rn 详情:<%=p1.getRepcontant() %>rn rn rn <% %>rnrn[color=#FF6600]servlet内容[/color]rnString flag=request.getParameter("flag");rn if(flag.equals("relist")) rn rn LiuyanOpr po=new LiuyanOpr();rn rn Integer aa=Integer.parseInt(request.getParameter("rid"));rn String sql = "select repcontant,repname,reptime,repid,thrid from replay where thrid="+ aa +" order by reptime desc";rn ArrayList list=po.research(sql);rn rn //将 查询到的信息 保存 到 session中rn HttpSession session=request.getSession(); //创建Sessionrn session.setAttribute("replaydetail", list);//将数据保存到Sessionrn rn //跳转页面rn response.sendRedirect("liuyanxq.jsp");//页面重定向rn rnrn[color=#FF6600]数据库操作类[/color]rnrnpublic ArrayList research(String sql) //获取查询rn rn ArrayList list = new ArrayList();rn try rn psmt = con.prepareStatement(sql);rn ResultSet rs = psmt.executeQuery();rn while(rs.next())rn Liuyan p = new Liuyan();rn p.setRepid(rs.getInt("repid"));rn p.setThrid(rs.getInt("thrid"));rn p.setRepname(rs.getString("repname"));rn p.setReptime(rs.getString("reptime"));rn p.setRepcontant(rs.getString("repcontant"));rn list.add(p);rn rn catch (SQLException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn rn return list; rn rnrnrnrnrn[color=#FF6600]报错[/color]rnrn2015-11-4 15:11:47 org.apache.catalina.core.StandardWrapperValve invokern严重: Servlet.service() for servlet jsp threw exceptionrnjava.lang.NullPointerExceptionrn at org.apache.jsp.liuyanxq_jsp._jspService(liuyanxq_jsp.java:180)rn at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rn at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384)rn at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)rn at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at com.biyesheji.srevlet.EncodingFilter.doFilter(EncodingFilter.java:32)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)rn at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216)rn at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)rn at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634)rn at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445)rn at java.lang.Thread.run(Thread.java:619)rnrnrn页面报错rntype Exception reportrnrnmessagernrndescription The server encountered an internal error () that prevented it from fulfilling this request.rnrnexceptionrnrnorg.apache.jasper.JasperException: An exception occurred processing JSP page /liuyanxq.jsp at line 121rnrn118: rn119: rn120: rn121: <%=p.getThrname() %><%=p.getThrtime() %>rn122: <%=p.getThrtitle() %>rn123: <%=p.getThrcontant() %> rn124: rnrnrnStacktrace:rn org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:515)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:426)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rn com.biyesheji.srevlet.EncodingFilter.doFilter(EncodingFilter.java:32)rnroot causernrnjava.lang.NullPointerExceptionrn org.apache.jsp.liuyanxq_jsp._jspService(liuyanxq_jsp.java:180)rn org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rn com.biyesheji.srevlet.EncodingFilter.doFilter(EncodingFilter.java:32)rnnote The full stack trace of the root cause is available in the Apache Tomcat/6.0.10 logs.rnrnApache Tomcat/6.0.10
菜鸟求助:::JdbcTemplet 一直空指针 求大神看看哪错了???
[img=https://img-bbs.csdn.net/upload/201411/24/1416830840_740656.png][/img]rn[img=https://img-bbs.csdn.net/upload/201411/24/1416830858_529179.png][/img]rn[img=https://img-bbs.csdn.net/upload/201411/24/1416830868_510300.png][/img]rn[img=https://img-bbs.csdn.net/upload/201411/24/1416830881_464360.png][/img]
第一次发帖,求大神看看为什么出现空指针
代码如下rnrnpublic class Test rn public static void main(String args[]) rn String s = "1,2;3,4,5;6,7,8,9;3,5";rn double[][] d = back(s);rn for(int i=0; i
请大神帮我看看,页面传递空指针
我在jsp页面配置rn rn我想給页面传递一个参数,http://localhost:8080/modifyUser.jsp?id=1,但是<%out.print("@@@@@@@"+oneUser.getId()); %>页面输出的id却是null,希望大神帮我看看哪里出错了,谢谢大家rnrn源码rn[code=java]rn<%@ page language="java" contentType="text/html; charset=UTF-8"rn pageEncoding="UTF-8"%>rnrnrnrnrnrn rnrn 修改个人信息rn rn rnrnrn rn rn <%out.print("@@@@@@@"+oneUser.getId()); %>rn rn rn 修改个人信息rn rn rn rn rn 用户名*:rn rn <%=oneUser.getUsername() %>rn rn rn 密码*:rn />rn rn rn 确认密码*:rn />rn rn rn 邮箱:rn />rn rn rn rn 性别rn rn rn 男 /> 女rn />rn rn rn rn rn 出生日期:rn /> rn rn rn rn =rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rnrnrn[/code]rnrnservlet代码rn[code=java]package com.dedo.BBS.Servlet;rnrnimport java.io.IOException;rnimport java.io.PrintWriter;rnimport java.text.ParseException;rnimport java.text.SimpleDateFormat;rnimport java.util.List;rnrnimport javax.servlet.ServletException;rnimport javax.servlet.http.HttpServlet;rnimport javax.servlet.http.HttpServletRequest;rnimport javax.servlet.http.HttpServletResponse;rnrnimport com.dedo.BBS.DataBean.BBSUser;rnimport com.dedo.BBS.Jdbc.JDBCOption;rnimport com.dedo.BBS.Jdbc.SQLConstant;rnimport com.dedo.BBS.Tool.Common;rnimport java.sql.Timestamp;rn/**rn * Servlet implementation class SaveUserrn */rnpublic class SaveUser extends HttpServlet rn private static final long serialVersionUID = 1L;rnrn /**rn * @see HttpServlet#HttpServlet()rn */rn public SaveUser() rn super();rn // TODO Auto-generated constructor stubrn rnrn /**rn * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponsern * response)rn */rn protected void doGet(HttpServletRequest request, HttpServletResponse response)rn throws ServletException, IOException rn processRequest(request, response);rn rnrn /**rn * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponsern * response)rn */rn protected void doPost(HttpServletRequest request, HttpServletResponse response)rn throws ServletException, IOException rn processRequest(request, response);rn rnrn /**rn * @param requestrn * @param responsern * @throws ServletExceptionrn * @throws IOExceptionrn */rn protected void processRequest(HttpServletRequest request, HttpServletResponse response)rn throws ServletException, IOException rn PrintWriter out = response.getWriter();rn try rn String security = request.getParameter("security");rn if (!request.getSession().getAttribute("security").toString()rn .equals(security)) rn out.println(Common.AlertBack("验证码不正确请重新输入验证码!"));rn return;rn else rn if(Common.isEmptyByString(request.getParameter("id")))rn rn addUser(out, request);rn rn elsern alterUser(out, request);rn rn rn rn finally rn out.close();rn rn rnrn /**注册信息rn * @param outrn * @param requestrn */rn private void addUser(PrintWriter out, HttpServletRequest request) rn List list = JDBCOption.query(SQLConstant.getUserByName, request.getParameter("username"));rn if (list.size() > 0) rn out.print(Common.AlertBack("用户名已经存在,请使用其他用户名"));rn return;rn rnrn BBSUser oneUser = new BBSUser();rn oneUser.setUsername(request.getParameter("username"));rn oneUser.setPassword(request.getParameter("password"));rn oneUser.setSex(Byte.parseByte(request.getParameter("gender")));rn oneUser.setEmail(request.getParameter("email"));rn SimpleDateFormat formatDate = new SimpleDateFormat("yyyy-MM-dd");rn try rn oneUser.setBirthday(formatDate.parse(request.getParameter("birthday")));rn catch (ParseException e) rn oneUser.setBirthday(null);rn rn JDBCOption.update(SQLConstant.adduser, oneUser.getUsername(), oneUser.getPassword(), oneUser.getSex(),rn oneUser.getEmail(),rn oneUser.getBirthday() == null ? null : new Timestamp(oneUser.getBirthday().getTime()));rnrn out.print(Common.AlertTo("恭喜" + oneUser.getUsername() + "注册", "/index.jsp"));rn rnrn /**修改信息rn * @param outrn * @param requestrn */rn private void alterUser(PrintWriter out, HttpServletRequest request) rn BBSUser oneUser = new BBSUser();rn oneUser.setId(Integer.parseInt(request.getParameter("id")));rn oneUser.setPassword(request.getParameter("password"));rn oneUser.setSex(Byte.parseByte(request.getParameter("gender")));rn oneUser.setEmail(request.getParameter("email"));rn SimpleDateFormat formatDate = new SimpleDateFormat("yyyy-MM-dd");rn try rn oneUser.setBirthday(formatDate.parse(requestrn .getParameter("birthdate")));rn catch (ParseException e) rn oneUser.setBirthday(null);rn rn JDBCOption.update(SQLConstant.updateUser, oneUserrn .getPassword(), oneUser.getSex(), oneUser.getEmail(),rn oneUser.getBirthday() == null ? null : new Timestamp(oneUserrn .getBirthday().getTime()),oneUser.getId());rn out.print(Common.AlertTo("恭喜修改成功!",rn "/index.jsp"));rn rnrnrn[/code]
哎,还是解决不了,求大神进来看看,麻烦了!
[code=SQL]rnCREATE TABLE `tb_single_product` (rn `id` int(11) NOT NULL auto_increment,rn `sigleUserId` varchar(50) default NULL,rn `provider` varchar(50) default NULL,rn `providerCountry` varchar(50) default NULL,rn `sku` varchar(50) default NULL,rn `developer` varchar(50) default NULL,rn `title` varchar(50) default NULL,rn `version` varchar(50) default NULL,rn `productType` varchar(50) default NULL,rn `units` int(50) default NULL,rn `developerProceeds` varchar(50) default NULL,rn `beginDate` timestamp NULL default NULL,rn `endDate` timestamp NULL default NULL,rn `customerCurrency` varchar(50) default NULL,rn `countryCode` varchar(50) default NULL,rn `currencyofProceeds` varchar(50) default NULL,rn `appleIdentifier` varchar(50) default NULL,rn `customerPrice` double default NULL,rn `promoCode` varchar(50) default NULL,rn `parentIdentifier` varchar(50) default NULL,rn `subscription` varchar(50) default NULL,rn `period` varchar(50) default NULL,rn PRIMARY KEY (`id`)rn)rnrnrninsert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('1','4','APPLE','US','DragonTownCN','Gate9','传奇小镇™','1.0.0','1','15','0','2013-09-08 00:00:00','2013-09-08 00:00:00','CAD','CA','CAD','535372564','0',NULL,NULL,NULL,NULL);rninsert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('2','4','APPLE','US','dragontown','Gate9','Dragon Town™','1.0.1','1','1','0','2013-09-08 00:00:00','2013-09-08 00:00:00','USD','BR','USD','535358467','0',NULL,NULL,NULL,NULL);rninsert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('3','4','APPLE','US','DragonTownCN','Gate9','传奇小镇™','1.0.0','1','9','0','2013-09-08 00:00:00','2013-09-08 00:00:00','GBP','GB','GBP','535372564','0',NULL,NULL,NULL,NULL);rninsert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('4','4','APPLE','US','DragonTownCN','Gate9','传奇小镇™','1.0.0','1','1','0','2013-09-08 00:00:00','2013-09-08 00:00:00','EUR','IE','EUR','535372564','0',NULL,NULL,NULL,NULL);rninsert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('5','4','APPLE','US','DragonTownCN','Gate9','传奇小镇™','1.0.0','1','3','0','2013-09-08 00:00:00','2013-09-08 00:00:00','USD','AM','USD','535372564','0',NULL,NULL,NULL,NULL);rninsert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('6','4','APPLE','US','DragonTownCN','Gate9','传奇小镇™','1.0.0','1','1','0','2013-09-08 00:00:00','2013-09-08 00:00:00','USD','AE','USD','535372564','0',NULL,NULL,NULL,NULL);rninsert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('7','4','APPLE','US','com.gate9pan.dragontown.unlimitedsteps',' ','Unlimited Steps',' ','IA1','3','60','2013-09-08 00:00:00','2013-09-08 00:00:00','JPY','JP','JPY','535370295','85',' ','dragontown',NULL,NULL);rninsert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('8','4','APPLE','US','dragontown','Gate9','Dragon Town™','1.0.1','7','60','0','2013-09-08 00:00:00','2013-09-08 00:00:00','CNY','CN','CNY','535358467','0',NULL,NULL,NULL,NULL);rninsert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('9','4','APPLE','US','dragontown','Gate9','Dragon Town™','1.0.1','7','18','0','2013-09-08 00:00:00','2013-09-08 00:00:00','USD','VN','USD','535358467','0',NULL,NULL,NULL,NULL);rninsert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('10','4','APPLE','US','dragontown','Gate9','Dragon Town™','1.0.1','1','2','0','2013-09-08 00:00:00','2013-09-08 00:00:00','USD','CO','USD','535358467','0',NULL,NULL,NULL,NULL);rninsert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('11','4','APPLE','US','DragonTownCN','Gate9','传奇小镇™','1.0.0','1','17','0','2013-09-08 00:00:00','2013-09-08 00:00:00','JPY','JP','JPY','535372564','0',NULL,NULL,NULL,NULL);rninsert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('12','4','APPLE','US','com.gate9pan.dragontown.unlimitedsteps',' ','Unlimited Steps',' ','IA1','1','.7','2013-09-08 00:00:00','2013-09-08 00:00:00','USD','US','USD','535370295','0',' ','dragontown',NULL,NULL);rninsert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('13','4','APPLE','US','DragonTownCN','Gate9','传奇小镇™','1.0.0','1','2','0','2013-09-08 00:00:00','2013-09-08 00:00:00','EUR','IT','EUR','535372564','0',NULL,NULL,NULL,NULL);rninsert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('14','4','APPLE','US','DragonTownCN','Gate9','传奇小镇™','1.0.0','1','1','0','2013-09-08 00:00:00','2013-09-08 00:00:00','EUR','ES','EUR','535372564','0',NULL,NULL,NULL,NULL);rninsert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('15','4','APPLE','US','dragontown','Gate9','Dragon Town™','1.0.1','1','1','.63','2013-09-08 00:00:00','2013-09-08 00:00:00','AUD','AU','AUD','535358467','0',NULL,NULL,NULL,NULL);rnrn[/code]rnrn关键字段说明 tilte:游戏名称,units:下载量,customerPrice:收益钱数,countryCode:地区代码rnrn我要查询出 某款游戏的最高下载量及地区代码 该游戏最高收益钱数及地区代码rnrn结果类似rnrn传奇小镇 最高下载量 最高下载的地区代码 最高收益 最高收益所在的地区代码rnDragon Town™ 最高下载量 最高下载的地区代码 最高收益 最高收益所在的地区代码rn游戏名称 :: :: :: :: :: ::rnrn求解啊 急死我了擦 sql太次了 得补一补了rn
求大神看看问题在哪
这是运行后的问题[img=https://img-bbs.csdn.net/upload/201412/23/1419323834_7542.png][/img]rn这是代码using System;rnusing System.Collections.Generic;rnusing System.ComponentModel;rnusing System.Data;rnusing System.Drawing;rnusing System.Linq;rnusing System.Text;rnusing System.Windows.Forms;rnusing System.Data.OleDb;rnnamespace LoginFormrnrn public partial class Form1 : Formrn rn public static string name;rn public static string psw;rn public static string right;rnrn public Form1()rn rn InitializeComponent();rn rnrn private void login_btn_Click(object sender, EventArgs e)rn rn if (this.textname.Text.Trim() == "" || textpsw.Text == "")rn rn MessageBox.Show("请输入您的用户名和密码!", "提示!");rn return;rn rnrn string Username = textname.Text;rn string Userpsw = textpsw.Text;rn rn if (Username == "" || Userpsw == "")rn rn MessageBox.Show("请输入用户名和密码!", "提示!");rn rn elsern rn OleDbConnection conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\\Documents\\Database2.accdb");rn rn if (radioButton1.Checked)rn rn string str = "select * from login where Usertight='" + this.textname.Text.Trim() + "'";rn tryrn rn conn.Open();rn OleDbCommand cmd = new OleDbCommand(str, conn);rn OleDbDataReader read = cmd.ExecuteReader();rn if (read.Read())rn rn if (textpsw.Text.Trim().Equals(read["Userpsw"].ToString().Trim()))rn rn MessageBox.Show("登录成功!", "欢迎登录本系统!");rn this.Hide();rn AdminLogin fm = new AdminLogin();rn fm.Show();rn rn elsern rn MessageBox.Show("密码输入错误,请重新输入!");rn rnrn rn rn catch (Exception ex)rn rn MessageBox.Show(ex.ToString());rn rn rn rn if (radioButton2.Checked)rn rn string str = "select * from stu where Userright='" + this.textname.Text.Trim() + "'";rn tryrn rn conn.Open();rn OleDbCommand cmd = new OleDbCommand(str, conn);rn OleDbDataReader read = cmd.ExecuteReader();rn if (read.Read())rn rn if (textpsw.Text.Trim().Equals(read["Userpsw"].ToString().Trim()))rn rn MessageBox.Show("登录成功!", "欢迎登录本系统!");rn this.Hide();rn StuLogin fm = new StuLogin();rn fm.Show();rn rn elsern rn MessageBox.Show("密码输入错误,请重新输入!");rn rn rn rn catch (Exception ex)rn rn MessageBox.Show(ex.ToString());rn rn rn if (radioButton1.Checked == false && radioButton2.Checked == false)rn rn MessageBox.Show("请选择权限!");rn rn rn rn rnrn private void cancel_btn_Click(object sender, EventArgs e)rn rn Application.Exit();rn rn rn
求Android大神过来看看,跪求啊~~
打开任意Android文档报错“org.eclipse.swt.custom.StyledText.getScrollbarsMode()I”
android 开发空指针异常 求大神帮忙看看
如题 求助解决方法。error log 如下:rn09-01 13:18:39.187: E/AndroidRuntime(21433): FATAL EXCEPTION: mainrn09-01 13:18:39.187: E/AndroidRuntime(21433): java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.getDrawingRect(android.graphics.Rect)' on a null object referencern09-01 13:18:39.187: E/AndroidRuntime(21433): at android.view.ViewGroup$ViewLocationHolder.init(ViewGroup.java:7297)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at android.view.ViewGroup$ViewLocationHolder.obtain(ViewGroup.java:7232)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at android.view.ViewGroup$ChildListForAccessibility.init(ViewGroup.java:7167)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at android.view.ViewGroup$ChildListForAccessibility.obtain(ViewGroup.java:7135)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at android.view.ViewGroup.dispatchPopulateAccessibilityEventInternal(ViewGroup.java:2729)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at android.view.View.dispatchPopulateAccessibilityEvent(View.java:5362)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at android.view.ViewGroup.dispatchPopulateAccessibilityEventInternal(ViewGroup.java:2735)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at android.view.View.dispatchPopulateAccessibilityEvent(View.java:5362)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at android.view.ViewGroup.dispatchPopulateAccessibilityEventInternal(ViewGroup.java:2735)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at android.view.View.dispatchPopulateAccessibilityEvent(View.java:5362)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at android.widget.RelativeLayout.dispatchPopulateAccessibilityEvent(RelativeLayout.java:1120)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at android.widget.AdapterView.onRequestSendAccessibilityEvent(AdapterView.java:949)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at android.view.ViewGroup.requestSendAccessibilityEvent(ViewGroup.java:740)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at android.view.ViewGroup.requestSendAccessibilityEvent(ViewGroup.java:744)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at android.view.ViewGroup.requestSendAccessibilityEvent(ViewGroup.java:744)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at android.view.ViewGroup.requestSendAccessibilityEvent(ViewGroup.java:744)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at android.view.View.sendAccessibilityEventUncheckedInternal(View.java:5330)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at android.view.View.sendAccessibilityEventUnchecked(View.java:5311)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at android.view.ViewRootImpl$SendWindowContentChangedAccessibilityEvent.run(ViewRootImpl.java:6948)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at android.view.ViewRootImpl$SendWindowContentChangedAccessibilityEvent.runOrPost(ViewRootImpl.java:6974)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at android.view.ViewRootImpl.postSendWindowContentChangedCallback(ViewRootImpl.java:6175)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at android.view.ViewRootImpl.notifySubtreeAccessibilityStateChanged(ViewRootImpl.java:6288)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at android.view.ViewGroup.notifySubtreeAccessibilityStateChanged(ViewGroup.java:2780)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at android.view.ViewGroup.notifySubtreeAccessibilityStateChanged(ViewGroup.java:2780)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at android.view.ViewGroup.notifySubtreeAccessibilityStateChanged(ViewGroup.java:2780)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at android.view.ViewGroup.notifySubtreeAccessibilityStateChanged(ViewGroup.java:2780)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at android.view.ViewGroup.notifySubtreeAccessibilityStateChanged(ViewGroup.java:2780)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at android.view.ViewGroup.notifySubtreeAccessibilityStateChanged(ViewGroup.java:2780)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at android.view.ViewGroup.notifySubtreeAccessibilityStateChanged(ViewGroup.java:2780)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at android.view.ViewGroup.notifySubtreeAccessibilityStateChanged(ViewGroup.java:2780)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at android.view.ViewGroup.notifySubtreeAccessibilityStateChanged(ViewGroup.java:2780)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at android.view.View.notifySubtreeAccessibilityStateChangedIfNeeded(View.java:8020)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at android.view.ViewGroup.addViewInner(ViewGroup.java:4005)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at android.view.ViewGroup.addView(ViewGroup.java:3794)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at android.view.ViewGroup.addView(ViewGroup.java:3735)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at com.app.myfolder.view.ScrollLayout.addView(ScrollLayout.java:213)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at android.view.ViewGroup.addView(ViewGroup.java:3708)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at com.app.myfolder.view.ScrollLayout.refreView(ScrollLayout.java:226)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at com.app.myfolder.activity.FoldersBoxActivity.initContainer(FoldersBoxActivity.java:675)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at com.app.myfolder.activity.FoldersBoxActivity.access$75(FoldersBoxActivity.java:658)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at com.app.myfolder.activity.FoldersBoxActivity$FolderAsyncTask.onPostExecute(FoldersBoxActivity.java:3110)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at com.app.myfolder.activity.FoldersBoxActivity$FolderAsyncTask.onPostExecute(FoldersBoxActivity.java:1)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at android.os.AsyncTask.finish(AsyncTask.java:636)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at android.os.AsyncTask.access$500(AsyncTask.java:177)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:653)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at android.os.Handler.dispatchMessage(Handler.java:102)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at android.os.Looper.loop(Looper.java:135)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at android.app.ActivityThread.main(ActivityThread.java:5254)rn09-01 13:18:39.187: E/AndroidRuntime(21433): at java.lang.reflect.Method.invokern
这是神马情况?求SSh大神···(空指针)
rn rn rn rn 个人信息rn rn 用户名:rn rn rn rn rn rn 真实姓名:rn rn rn rn rnrn rn 电子邮箱: rn ">rn rn rn rn 联系电话:rn rn ">rn rn rn rn 修改信息rn 返回 rn rn rnrn 点保存的时候:地址栏如下rnhttp://localhost:8080/scnupm/student/updataStudent?person.password=&person.id=&person.type=&person.account=fuhuasishui&person.name=%E5%BC%A0%E6%98%8E%E5%8D%8E&person.email=15521267125%40163.com&person.telephone=13560134432rn×××××××××××××××××××××××××××××××××××××××××××××××××××××××rn Structs配置如下:rn rn /student/personalmanage.jsprn rn rn rn /student/personalmanage.jsprn rn×××××××××××××××××××××××××××××××××××××××××××××××××××××××Action的函数如下: rnpublic String execute() throws Exception rn tryrn System.out.println(person.getId()+":test0");rn studentService.updataStudent(person);rn catch(Exception e)rn e.printStackTrace();rn rn return SUCCESS;rn rn控制台输出的为:rnnull:test0rnrnjava.lang.NullPointerExceptionrn at cn.edu.scnu.cs.scnupm.service.impl.StudentServiceImpl.updataStudent(StudentServiceImpl.java:61)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)rn at java.lang.reflect.Method.invoke(Method.java:597)rn at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)rn at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)rn at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)rn at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)rn at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)rn at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)rn at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)rn at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)rn at $Proxy9.updataStudent(Unknown Source)rn at cn.edu.scnu.cs.scnupm.action.person.UpdataStudentAction.execute(UpdataStudentAction.java:19)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)rn at java.lang.reflect.Method.invoke(Method.java:597)rn at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:452)rn at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:254)rn ·····rnserver层的代码为rn public boolean updataStudent(Person user) rn if (persondao.findById(user.getId()) != null) rn // 如果存在则调用dao组件删除srn persondao.update(user);rn System.out.println(user.getId()+":test"); (!控制台没有输出这个)rn else rn System.out.println("false:test");rn return false;rn rn return true;rn
Android界面切换问题,一直解决不了,求帮助
我要进行两个相互依赖的两个activiti之间进行切换,我在第一个activity中定义的切换按钮的监听事件如下rnchange.setOnClickListener(new Button.OnClickListener()rn public void onClick(View v)rn Intent intent = new Intent();rn intent.setClass(Calcute.this, Thesecond.class);rn Bundle bundle = new Bundle();rn bundle.putString("Content", tx1.getText().toString());rn intent.putExtras(bundle);rn startActivity(intent);rn rn rn );rn但是运行虚拟器时,一点这个按钮就强行关闭,退出程序了,我已经在Mainfest中定义了新的Activiti了rn报错信息如下[img=http://img.my.csdn.net/uploads/201212/11/1355232867_3406.PNG][/img]
android空指针问题
public class FiveActivity extends Activity rn private TextView textView;rn rn private Handler handler = new Handler()rn public void handleMessage(android.os.Message msg) rn rn ;rn ;rn rn @Overridern protected void onCreate(Bundle savedInstanceState) rn // TODO Auto-generated method stubrn super.onCreate(savedInstanceState);rn setContentView(R.layout.five);rn textView = (TextView) findViewById(R.id.textview);rn new Thread()rn public void run() rn try rn Thread.sleep(2000);rn rn handler.post(new Runnable() rn rn @Overridern public void run() rn // TODO Auto-generated method stubrn textView.setText("ok");rn rn );rn catch (InterruptedException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn rn rn .start();rn rnrnrn报错是textView.setText("ok");空指针rnrnrnrn
Spring注入类报空指针错误求大神
[img=https://img-bbs.csdn.net/upload/201603/15/1458019934_504303.png][/img][img=https://img-bbs.csdn.net/upload/201603/15/1458019779_27368.png][/img][img=https://img-bbs.csdn.net/upload/201603/15/1458019797_42521.png][/img]rn就是这样,然后那个javaMailSenderImpl类我也提供了getter和setter,但是运行的结果是这样的![img=https://img-bbs.csdn.net/upload/201603/15/1458020120_49380.png][/img]
空指针错误 求大神帮忙 急
[img=https://img-bbs.csdn.net/upload/201806/25/1529913206_313148.png][/img]rn如果可以能加个微信细谈的最好 本人小白
shiro框架报错空指针,求大神帮忙
下面代码是shiro中的权限验证部分代码,List posts打印不出来,从这里开始报错。rn没加入权限验证的时候 用户登录验证是可以用的,在外面使用相同的语句 posts是可以打印出来的。求大神指点。rn[code=java]public class UserRealm extends AuthorizingRealm rnrn @Resourcern UserinfoService userinfoService;rn PostsService postsService;rn rn// 访问权限rn @Overridern protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection token) rn String userName = (String) token.getPrimaryPrincipal(); //获取用户名usersbmrn System.out.println(userName);rn Set roles =new HashSet();//创建身份rn System.out.println(roles);rn List posts = postsService.QueryPosts(); //查询所有权限信息保存到postsrn System.out.println(posts);rn Userinfo userinfo = userinfoService.QueryUserByUsersbm(userName);rn int userposts=userinfo.getUserclass();//获取用户等级rn int one= posts.get(0).getPostclass();//设置权限one等于数据库内第一个权限用户的postclassrn int two=posts.get(1).getPostclass();rn int three=posts.get(2).getPostclass();rn int four=posts.get(3).getPostclass();rn int five=posts.get(4).getPostclass();rn rn //为roles 添加对应 postsclass的中文身份。rn if (userposts==one) rn roles.add(posts.get(0).getPosts());rn rn if (userposts==two) rn roles.add(posts.get(1).getPosts());rn rn if (userposts==three) rn roles.add(posts.get(2).getPosts());rn rn if (userposts==four) rn roles.add(posts.get(3).getPosts());rn rn if (userposts==five) rn roles.add(posts.get(4).getPosts());rn rn rn Set permissions = new HashSet();rn// //所有用户可以访问的地址:rn permissions.add("/login");rn permissions.add("/dologin");rn permissions.add("/QueryStationByLines");rn permissions.add("/QueryCodexByStation");rn permissions.add("/QueryUserByStation");rn permissions.add("/index");rn// //权限用户可以访问的地址:rn if(userposts == one)rn permissions.add("/upuserpwd");rn rn rn SimpleAuthorizationInfo authorizationInfo = new SimpleAuthorizationInfo();rn authorizationInfo.addRoles(roles);//设置角色rn authorizationInfo.addStringPermissions(permissions);//设置权限rn return authorizationInfo;rn// return null;rn rn [/code]rnrnweb.xml中的配置rn[code=text] rn rn shiroFilterrn rn org.springframework.web.filter.DelegatingFilterProxyrn rn rn rn shiroFilterrn /*rn rn rn rn org.springframework.web.context.ContextLoaderListenerrn rn rn rn contextConfigLocation rn classpath:applicationContext.xml rn [/code]rnapplicationContext.xml中的配置:rn[code=text] rnrn rn rn rnrn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn /login = anonrn /dologin = anonrn /QueryStationByLines = anonrn /QueryCodexByStation = anonrn /QueryUserByStation = anonrn /static/** = anonrn /** = authcrn /** = permsrn rn rn [/code]rn
android重写adapter的问题?
比如我现在有个类rnpublic class MsgEntity rn public int MsgId; rn public String Name; rn public float Grade; rn.......rn然后 List msgList = new ArrayList(); 最后将数据载入msgList.add(msg);rn我要将这些数据显示到listView上,需要重写个adapter封装list。每条List就是MsgEntity类下的MsgId,Name,Grade显示在三个editText上。请问大神,这个adapter怎么写?(怎么让 MsgId,Name,Grade 的字符串数据 和 三个eiditText关联)
android的adapter问题
android项目开发中,可以用simpleadapter直接获取数据库数据吗?rn需要自己重新写一个适配器吗?rn我就是想要实现一个ListVIew,其中每个Item有6个TextViewrn我觉得用simpleadapter是可以实现的rn可是 运行起来就是一堆叉叉,郁闷啊
Android空指针问题
Android解析xml获取了控件的应用,但在使用控件的时候总是报空指针异常,这种现象时有时无,以前clean一下就没问题了,现在clean了也没有用,不知道有遇上这样的问题的没,还请指教这种现象的原因及解决办法。
android程序运行空指针问题。
调试程序报错空指针。rn我是在网上找别人的代码。rnrn[color=#FF0000]Mylocation.java[/color]rn rn rnrnpackage com.swift.mylocation;rn rnimport java.io.IOException;rn import java.util.List;rn import java.util.Locale;rn rnimport android.app.PendingIntent;rn rnimport android.content.Context;rn import android.content.Intent;rn rnimport android.location.Address;rn import android.location.Criteria;rn import android.location.Geocoder;rn import android.location.Location;rn import android.location.LocationListener;rn import android.location.LocationManager;rn import android.os.Bundle;rn rn rn rnimport android.widget.TextView;rn import android.widget.Toast;rn rnimport com.google.android.maps.GeoPoint;rn import com.google.android.maps.MapActivity;rn import com.google.android.maps.MapController;rn import com.google.android.maps.MapView;rn import com.google.android.maps.Overlay;rn import com.swift.mylocation.R;rn rnpublic class Mylocation extends MapActivity rn rn MapController mapController;rn List overlays;rn MyPositionOverlay positionOverlay;rn LocationManager locationManager;rn MapView myMapView;rn rn final String PROXIMITY_ALERT = new String(rn "android.intent.action.proximityalert");rn rn @SuppressWarnings("deprecation")rn @Overridern public void onCreate(Bundle icicle) rn super.onCreate(icicle);rn setContentView(R.layout.main);rn rn myMapView = (MapView) findViewById(R.id.myMapView);rn rn mapController = myMapView.getController();rn rn myMapView.setSatellite(true);rn myMapView.setStreetView(true);rn myMapView.displayZoomControls(false);rn rn mapController.setZoom(17);rn rn positionOverlay = new MyPositionOverlay();rn overlays = myMapView.getOverlays();rn overlays.add(positionOverlay);rn rn Criteria criteria = new Criteria();rn criteria.setAccuracy(Criteria.ACCURACY_FINE);rn criteria.setAltitudeRequired(true);rn criteria.setBearingRequired(false);rn criteria.setCostAllowed(false);rn criteria.setPowerRequirement(Criteria.POWER_LOW);rn locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);rn rn String provider = locationManager.getBestProvider(criteria, true);rn rn Location location = locationManager.getLastKnownLocation(provider);rn rn updateWithNewLocation(location);rn rn locationManager.requestLocationUpdates(provider, 2000, 10,rn locationListener);rn rn setProximityAlert();rn rn rn rn private final LocationListener locationListener = new LocationListener() rn @Overridern public void onLocationChanged(Location location) rn updateWithNewLocation(location);rn rn rn @Overridern public void onProviderDisabled(String provider) rn updateWithNewLocation(null);rn rn rn @Overridern public void onProviderEnabled(String provider) rn rn rn @Overridern public void onStatusChanged(String provider, int status, Bundle extras) rn rn ;rn rn rn rn rn void setProximityAlert() rn rn double lat = 31.620356666666666;rn double lng = 121.38631333333333;rn float radius = 50f;rn long expiration = -1;rn rn Intent intent = new Intent(PROXIMITY_ALERT);rn intent.setAction(PROXIMITY_ALERT);rn PendingIntent proximityIntent = PendingIntent.getBroadcast(this, -1,rn intent, 0);rn rn locationManager.addProximityAlert(lat, lng, radius, expiration,rn proximityIntent);rn rn rn rn /** Update UI with a new location */rn private void updateWithNewLocation(Location location) rn rn String latLongString;rn TextView myLocationText;rn myLocationText = (TextView) findViewById(R.id.myLocationText);rn String addressString = "No address found";rn if (location != null) rn rn positionOverlay.setLocation(location);rn rn Double geoLat = location.getLatitude() * 1E6;rn Double geoLng = location.getLongitude() * 1E6;rn GeoPoint point = new GeoPoint(geoLat.intValue(), geoLng.intValue());rn mapController.animateTo(point);rn rn double lat = location.getLatitude();rn double lng = location.getLongitude();rn latLongString = "Lat:" + lat + "\nLong:" + lng;rn double latitude = location.getLatitude();rn double longitude = location.getLongitude();rn rn Geocoder gc = new Geocoder(this, Locale.CHINA);rn try rn List addresses = gc.getFromLocation(latitude,rn longitude, 1);rn StringBuilder sb = new StringBuilder();rn if (addresses.size() > 0) rn Address address = addresses.get(0);rn for (int i = 0; i < address.getMaxAddressLineIndex(); i++)rn sb.append(address.getAddressLine(i)).append("\n");rn sb.append(address.getCountryName());rn sb.append(address.getLocality()).append("\n");rn rn addressString = sb.toString();rn catch (IOException e) rn rn else rn latLongString = "No location found";rn rn myLocationText.setText("Your Current Position is:\n" + latLongStringrn + "\n" + addressString);rn rn Toast.makeText(this,this.getIntent().getStringExtra(PROXIMITY_ALERT) , Toast.LENGTH_LONG);rn rn rn @Overridern protected boolean isRouteDisplayed() rn return true;rn rn rn rnrn rn rn[color=#FF0000]MyPostionOverlay.java[/color]rn rn rn rnrnpackage com.swift.mylocation;rn rnimport android.graphics.Canvas;rn import android.graphics.Paint;rn import android.graphics.Point;rn import android.graphics.RectF;rn import android.location.Location;rn rnimport com.google.android.maps.GeoPoint;rn import com.google.android.maps.MapView;rn import com.google.android.maps.Overlay;rn import com.google.android.maps.Projection;rn rnpublic class MyPositionOverlay extends Overlay rn rn Location location, mlocation;rn final Double lat = 31.620356666666666 * 1E6,rn lon = 121.38631333333333 * 1E6;rn final int ccc = 50;rn private final int mRadius = 5;rn rn /**rn * @return the locationrn */rn public Location getLocation() rn return location;rn rn rn /**rn * @param locationrn * the location to setrn */rn public void setLocation(Location location) rn this.location = location;rn rn rn @Overridern public void draw(Canvas canvas, MapView mapView, boolean shadow) rn Projection projection = mapView.getProjection();rn if (shadow == false) rn rn Double latitude = location.getLatitude() * 1E6;rn Double longitude = location.getLongitude() * 1E6;rn GeoPoint geoPoint, gp;rn geoPoint = new GeoPoint(latitude.intValue(), longitude.intValue());rn gp = new GeoPoint(lat.intValue(), lon.intValue());rn rn Point point = new Point();rn projection.toPixels(geoPoint, point);rn RectF oval = new RectF(point.x - mRadius, point.y - mRadius,rn point.x + mRadius, point.y + mRadius);rn rn Paint paint = new Paint();rn paint.setARGB(250, 255, 0, 0);rn paint.setAntiAlias(true);rn paint.setFakeBoldText(true);rn Paint backPaint = new Paint();rn backPaint.setARGB(175, 50, 50, 50);rn backPaint.setAntiAlias(true);rn RectF backRect = new RectF(point.x + 2 + mRadius, point.y - 3rn * mRadius, point.x + 65, point.y + mRadius);rn rn Point center = new Point();rn rn projection.toPixels(gp, center);rn rn Paint ccp = new Paint();rn ccp.setARGB(250, 0, 0, 255);rn ccp.setAntiAlias(true);rn rn canvas.drawCircle(center.x, center.y, ccc, ccp);rn rn canvas.drawOval(oval, paint);rn canvas.drawRoundRect(backRect, 5, 5, backPaint);rn canvas.drawText("Here I Am", point.x + 2 * mRadius, point.y, paint);rn rn rn super.draw(canvas, mapView, shadow);rn rn rn @Overridern public boolean onTap(GeoPoint point, MapView mapView) rn return false;rn rn rn
Android程序空指针问题
问题出现的截图如图1:rn[img=https://img-bbs.csdn.net/upload/201508/24/1440424964_626709.png][/img]rn我在MainActivity中定义数据库:rn[img=https://img-bbs.csdn.net/upload/201508/24/1440424962_366952.png][/img]rn然后将他传入AppActivity中:rn[img=https://img-bbs.csdn.net/upload/201508/24/1440424987_776251.png][/img]rn接下来出错的49行,56行,102行如图所示,请问各位大神们,问题可能出在哪里呢?rn[img=https://img-bbs.csdn.net/upload/201508/24/1440425069_171809.png][/img]rn[img=https://img-bbs.csdn.net/upload/201508/24/1440425010_789817.png][/img]
list.setAdapter(adapter)空指针,就几行代码。大神来看看
主方法:rnpackage com.example.students;rnrnrnimport android.app.Activity;rnrn rnimport android.os.Bundle;rnimport android.widget.ListView;rnrnrnpublic class MainActivity extends Activity rn private String[] ss = new String[]rn "北京1",rn "北京2",rn "北京3",rn "北京4",rn rn rn ;rnprivate ListView list;rn @Overridern protected void onCreate(Bundle savedInstanceState) rn super.onCreate(savedInstanceState);rn setContentView(R.layout.activity_main);rn list = (ListView) findViewById(android.R.id.list);rn MyAdapter adapter = new MyAdapter(this,ss);rn list.setAdapter(adapter);rn rnrn rnrnrn这个是My adapter:rnpackage com.example.students;rnrnimport android.content.Context;rnimport android.view.View;rnimport android.view.ViewGroup;rnimport android.widget.BaseAdapter;rnimport android.widget.TextView;rnrnpublic class MyAdapter extends BaseAdapterrnprivate Context context;rnprivate String[] ss;rnpublic MyAdapter(Context context, String[] ss) rn super();rn this.context = context;rn this.ss = ss;rnrn@Overridernpublic int getCount() rn // TODO Auto-generated method stubrn return ss.length;rnrn@Overridernpublic Object getItem(int position) rn // TODO Auto-generated method stubrn return null;rnrn@Overridernpublic long getItemId(int position) rn // TODO Auto-generated method stubrn return 0;rnrn@Overridernpublic View getView(int position, View convertView, ViewGroup parent) rn // TODO Auto-generated method stubrn String str = ss[position];rn TextView textview = new TextView(context);rn textview.setText(str);rn return textview;rnrn rn rnrnrn最后是listview:rnrnrn rn rn rn rnrnrnrn
tomcat启动闪退错误解决不了,求大神!!!!!
我的jdk版本是11,tomcat版本是9。为什么我在用startup.bat启动tomcat的时候一直报这个错,弄了一晚上了,心态炸了,求大神棒棒忙[face]qq:9.gif[/face]rn[img=https://img-bbs.csdn.net/upload/201905/14/1557784585_520426.png][/img]
这个报错一直解决不了,求大神解决!!!!!
可能存在类似的问题:n![图片说明](https://img-ask.csdn.net/upload/201707/20/1500542651_757372.png)
求大神帮我看看!
请问一个问题 我在主窗体的panel容器里添加了一个Form子窗体 也实现了点击后子窗体最大化的效果 但是在主窗体不是最大化的时候点击弹出子窗体后 我去把主窗体最大化之后 Form子窗体不会跟随panel的尺寸改变 rnrn private void Form1_Load(object sender, EventArgs e)rn rn this.WindowState = System.Windows.Forms.FormWindowState.Maximized;rn this.panelFrom.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;rn this.label1.ForeColor = Color.LightPink;rn rnrnrn private void OpenForm(Form objForm)rn rn objForm.TopLevel = false;//将子窗体设置成费顶级控件rn objForm.WindowState = FormWindowState.Maximized;//设置窗体最大化rn objForm.FormBorderStyle = FormBorderStyle.None;//去掉窗体边框rn objForm.Dock = System.Windows.Forms.DockStyle.Fill;//设置子窗体属性为Fillrn //objForm.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right | System.Windows.Forms.AnchorStyles.Top |System.Windows.Forms.AnchorStyles.Bottom;rn objForm.Parent = this.panelFrom;//指定当前子窗体显示的容器rn this.panelFrom.Controls.Add(objForm);rn objForm.Show();rnrn rnrn private void 合同履行情况ToolStripMenuItem_Click(object sender, EventArgs e)rn rn FrmContract objForm = new FrmContract();rn this.OpenForm(objForm);rn rnrn private void panelFrom_SizeChanged(object sender, EventArgs e)rn rn foreach(Control ctrl in this.panelFrom.Controls)rn rn if (ctrl is Form)rn rn ctrl.Height = this.panelFrom.Height;rn ctrl.Width = this.panelFrom.Width;rn rn rn rn
求大神帮忙 看看!!
Fatal error: Call to a member function recordcount() on a non-object in C:\Users\Administrator\Desktop\oecsm\Apache2\htdocs\classes\user.class.php on line 34rnrnrn项目更改数据库之后就报这个错!
求大神给看看
发不了邮件,求大神看看哪儿有问题rn rn protected void btbConfirm_Click(object sender, EventArgs e)rn rn string str1 = "select * from yhxxb where dzyx='" + txtEmail.Text + "' and yhm='" + txtUsername.Text + "'";rn if (DataBase.ExecuteRead(str1))rn rn SendMessage();rn rn elsern rn DataBase.AlertMessagge(Page,"",GetType(),"用户名或邮箱错误!");rn rn rn public void SendMessage()rn rn string sqlcon = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["myConnection"].ConnectionString;rn string str1 = "select * from yhxxb where dzyx='" +txtEmail.Text + "' and yhm='" + txtUsername.Text + "'";rn SqlConnection con = new SqlConnection(sqlcon);rn con.Open();rn SqlCommand cmd = new SqlCommand(str1, con);rn SqlDataReader dr = cmd.ExecuteReader();rn if (dr.Read())rn rn //取数据库中的用户名和密码rn string password = dr["mm"].ToString();rn string username = dr["yhm"].ToString();rn MailMessage mail = new MailMessage("982112101@qq.com","'" + txtEmail.Text.Trim() + "'");rn mail.Subject = "找回密码";rn mail.Body = "用户您好 您的用户名为:'" + username + "' 您的密码为:'" + password + "' 请妥善保管!";rn mail.IsBodyHtml = true; // 是否是HTML格式rn SmtpClient smtp = new SmtpClient();rn smtp.Host = "smtp.qq.com";//QQ的SMPT服务器IPrn smtp.Port = 25;//SMPT端口号,一般为25rn smtp.Credentials = new System.Net.NetworkCredential("982112101@qq.com","321"); //指定登录服务器(即邮箱的帐号和密码)的用户名和密码,注意要在自己邮箱中设置开启SMTP服务rn tryrn rn smtp.Send(mail);rn rn catch (SmtpException ex)rn rn Response.Write(ex.Message);rnrn rn dr.Close();rn con.Close();rn rn rnrn参数或变量中有语法错误。 服务器响应为: Bad address syntaxrn
求大神看看
我现在讲word文档,以二进制形式写入到sqlserver,但是当我导出word的时候,却提示下面这个,但是word还是能打开的。rn[img=https://img-bbs.csdn.net/upload/201311/01/1383298776_123975.png][/img]rnrn03格式的word不会报错,只有docx的才会爆这个错!rnrn下面是代码:rnrn[code=csharp] private void bt_cnMSDS_Find_Click(object sender, RoutedEventArgs e)rn rn SqlConnection conn = null;rn System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog();rn if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)rn rn conn = DBHelper.c;rn string code = getLastDB("select top 1 QDSS_DICode from QDSS_DocumentInfo order by QDSS_DICode desc");rn tb_miCHMSDSFile.Text = (Convert.ToInt32(code) + 1).ToString("00000000");rn tryrn rnrn byte[] _byte;rn string f = ofd.FileName;rn FileStream fs = new FileStream(f, FileMode.Open);rn BinaryReader br = new BinaryReader(fs);rn _byte = new byte[fs.Length];rn br.Read(_byte, 0, Convert.ToInt32(fs.Length));rn conn.Open();rn string sqlstring = "insert into QDSS_DocumentInfo(QDSS_DICode,QDSS_DIName,QDSS_DIContent,QDSS_DIOperNode) values(@code,@name,@pdf,@node)";rn SqlCommand cmd = new SqlCommand(sqlstring, conn);rn cmd.Parameters.Add("@pdf", SqlDbType.Image, _byte.Length).Value = _byte;rn cmd.Parameters.Add("@code", SqlDbType.Char, 10).Value = tb_miCHMSDSFile.Text;rn cmd.Parameters.Add("@name", SqlDbType.VarChar, 100).Value = System.IO.Path.GetFileName(ofd.FileName);rn cmd.Parameters.Add("@node", SqlDbType.VarChar, 50).Value = "中文MSDS文档";rn cmd.ExecuteNonQuery();rn MessageBox.Show("OK");rn br.Close();rn fs.Close();rn rn catch (Exception ex)rn rn MessageBox.Show("暂不支持添加此种类型的文档!", "错误提示", MessageBoxButton.OK, MessageBoxImage.Error);rn rn finallyrn rn rn conn.Close();rn rn rn elsern rn return;rn rn rn /// rn /// 2013年10月23日16:12:55 李森 打开中文MSDS文档rn /// rn /// rn /// rn private void bt_cnMSDS_Open_Click(object sender, RoutedEventArgs e)rn rn string path = string.Empty;//路径rn string name = string.Empty;//文件名rn string sql = "select QDSS_DICode,QDSS_DIName,QDSS_DIContent from QDSS_DocumentInfo where QDSS_DICode ='" + tb_miCHMSDSFile.Text + "'";rn SqlConnection conn = DBHelper.c;rn SqlCommand cmd = new SqlCommand(sql, conn);rn conn.Open();rn SqlDataReader reader = cmd.ExecuteReader();rn while (reader.Read())rn rn string id = reader["QDSS_DICode"].ToString();rn name = reader["QDSS_DIName"].ToString();rn byte[] fileBytes = (byte[])reader["QDSS_DIContent"];rn if (fileBytes.Length == 0)rn rn MessageBox.Show(name + "未找到!");rn return;rn rn path = System.IO.Path.GetTempPath() + "WTSoft";rn tryrn rn if (Directory.Exists(path))rn rn foreach (string d in Directory.GetFileSystemEntries(path))rn rn if (File.Exists(d))rn rn File.Delete(d);rn rn rn Directory.Delete(path);rn rn DirectoryInfo dir = Directory.CreateDirectory(path);//创建文件夹rn rn catch (Exception ex)rn rn MessageBox.Show(ex.Message, "错误提示", MessageBoxButton.OK, MessageBoxImage.Error);rn rn int arraysize = new int();rn arraysize = fileBytes.GetUpperBound(0);rn FileStream fs = new FileStream(path + "\\" + name, FileMode.Create);rn BinaryWriter bw = new BinaryWriter(fs);rn bw.Write(fileBytes, 0, arraysize);rn bw.Close();rn fs.Close();rnrn rn if (name == null || name == "")rn rn MessageBox.Show("文档为空,无法打开", "提示信息", MessageBoxButton.OK, MessageBoxImage.Exclamation);rn rn elsern rn tryrn rn System.Diagnostics.Process.Start(path + "\\" + name);rn rn catch (Exception ex)rn rn MessageBox.Show(ex.Message);rn rn rnrn conn.Close();rn [/code]
求大神帮忙,!看看
/* 题目:一球从100米高度自由落下,rn * 每次落地后反跳回原高度的一半;rn * 再落下,求它在 第N次落地时,共经过多少米?rn * 第N次反弹多高?(将处理写到方法中,rn * 并且方法需要带一个参数,该参数表示第N次落地)rn */import java.util.Scanner;rnpublic class Test3 rnrn rn public static double method(int k)rn rn double sum=100;rn double h=100;rn for(int i=1;i<=k;i++)rn rn sum+=h/2*2;rn h=h/2;rn rn return sum;rn rn rn rnrn public static void main(String[] args)rn rn Scanner scanner=new Scanner(System.in);rn System.out.println("请输入第N次数:");rn int n=scanner.nextInt();rn double y=method(n);rn System.out.println(y);rnrn rn rn rn rn rn rnrn我的方案不行!求大神帮忙!rn
求大神帮忙看看
public static void main(String[] args)rn System.out.println(getFormatNum("0.000",1.2224));rn System.out.println(getFormatNum("0.000",1.2225));rn System.out.println(getFormatNum("0.000",1.2226));rn System.out.println(getFormatNum("0.000",0.2224));rn System.out.println(getFormatNum("0.000",0.2225));rn System.out.println(getFormatNum("0.000",0.2226));rn System.out.println(getFormatNum("0.000",2.4924));rn System.out.println(getFormatNum("0.000",2.4925));rn System.out.println(getFormatNum("0.000",2.4926));rn rn rn public static Double getFormatNum(String pattren,Double data)rn String reStr = "";rn reStr = new java.text.DecimalFormat(pattren).format(data); rn return Double.parseDouble(reStr);rn rn为什么执行结果会是rn1.222rn1.222rn1.223rn0.222rn0.223rn0.223rn2.492rn2.493rn2.493rn当个位为1时并没有按照四舍五入的规则执行
初学咋练 解决不了 求大神啊
using System;rnusing System.Collections.Generic;rnusing System.Linq;rnusing System.Text;rnusing System.Data;rnrnusing ESRI.ArcGIS.Geometry;rnusing ESRI.ArcGIS.Geodatabase;rnusing ESRI.ArcGIS.DataSourcesFile;rnusing ESRI.ArcGIS.Carto;rnusing ESRI.ArcGIS.ArcMap;rnrnrnnamespace MapControlApplication3rnrn rn class DataOperatorrn rn //保存当前地图对象。rn public IMap m_map;rnrn //用于传入当前地图对象。rn public DataOperator(IMap map)rn rn m_map = map;rn rn public ILayer GetLayerByName(String sLayerName)rn rn //判断图层名或地图对象 是否为空。若为空,函数返回空。rn if (sLayerName == "" || m_map == null)rn rn return null;rn rn //对地图对象中的所有图层进行遍历。若某一图层的名称与指定图层名相同,则返回该图层。rn for (int i = 0; i < m_map.LayerCount; i++)rn rn if (m_map.get_Layer(i).Name == sLayerName)rn rn return m_map.get_Layer(i);rn rn rn //若地图对象中的所有图层名均与指定图层名不匹配,函数返回空。rn return null;rn rn public DataTable GetContinentsNames()rn rn //获取“Continents”图层,利用IFeatureLayer接口访问,并判断是否成功。若失败,rn //函数返回空。rn ILayer layer = GetLayerByName("Continents");rn IFeatureLayer featureLayer = layer as IFeatureLayer;rn if (featureLayer == null)rn rn return null;rn rn //调用IFeatureLayer接口的Seach方法,获取要素指针(IFeatureCursor)接口对象,rn //用于在之后遍历图层中的全部要素,并判断是否成功获取第一个要素。若失败,函数返回空。rn IFeatureLayer feature;rn IFeatureCursor featureCursor = featureLayer.Search(null,false);rn feature = featureCursor.NextFeature();rn if (feature == null)rn rn return null;rn rn //新建DataTable类型对象,用于函数返回。rn DataTable dataTable = new DataTable();rnrn //新建DataColum类型对象,分别保存各个洲的序号和名称。设置完毕后,加入DataTable的列集合(Columns)中。rn DataColumn dataColumn = new DataColumn();rn dataColumn.ColumnName = "序号";rn dataColumn.DataType = System.Type.GetType("System.Int32");rn dataTable.Columns.Add(dataColumn);rnrn dataColumn = new DataColumn();rn dataColumn.ColumnName = "名称";rn dataColumn.DataType = System.Type.GetType("System.String");rn dataTable.Columns.Add(dataColumn);rnrn //对图层中的要素进行遍历。每次获取一个要素,就关联DataTable的下一个DataRow,将要素在序号和名称字段上的值赋给DataRow的对应列中。rn //在“Continents”图层属性表中,序号信息在第0个字段中,名称信息在第2个字段中。相关内容可以通过ArcMap对地图文档进行查看。rn DataRow dataRow;rn while (feature != null)rn rn dataRow = dataTable.NewRow();rn dataRow[0] = feature.get_Value(0);rn dataRow[1] = feature.get_Value(2);rn dataTable.Rows.Add(dataRow);rnrnrn feature = featureCursor.NextFeature();rn rn //返回设置好的数据表。rn return dataTable;rn rn rn rnrnrn错误 2 “ESRI.ArcGIS.Carto.IFeatureLayer”不包含“get_Value”的定义,并且找不到可接受类型为“ESRI.ArcGIS.Carto.IFeatureLayer”的第一个参数的扩展方法“get_Value”(是否缺少 using 指令或程序集引用?) D:\袁\冯瑶-201220791\MapControlApplication3\MapControlApplication3\DataOperator.cs 84 38 MapControlApplication3rn错误 3 “ESRI.ArcGIS.Carto.IFeatureLayer”不包含“get_Value”的定义,并且找不到可接受类型为“ESRI.ArcGIS.Carto.IFeatureLayer”的第一个参数的扩展方法“get_Value”(是否缺少 using 指令或程序集引用?) D:\袁\冯瑶-201220791\MapControlApplication3\MapControlApplication3\DataOperator.cs 85 38 MapControlApplication3rn错误 1 无法将类型“ESRI.ArcGIS.Geodatabase.IFeature”隐式转换为“ESRI.ArcGIS.Carto.IFeatureLayer”。存在一个显式转换(是否缺少强制转换?) D:\袁\冯瑶-201220791\MapControlApplication3\MapControlApplication3\DataOperator.cs 59 23 MapControlApplication3rn错误 4 无法将类型“ESRI.ArcGIS.Geodatabase.IFeature”隐式转换为“ESRI.ArcGIS.Carto.IFeatureLayer”。存在一个显式转换(是否缺少强制转换?) D:\袁\冯瑶-201220791\MapControlApplication3\MapControlApplication3\DataOperator.cs 89 27 MapControlApplication3rn
求大神帮助检查错误,小白解决不了了,,,
我按照书上的程序敲了一个图轮廓线的设计的程序,但是书上给的是一段升程的,我设计的是三段,如下图滚子位移曲线所示。[img=https://img-bbs.csdn.net/upload/201709/07/1504779160_909235.jpg][/img]我对书上程序有一些改动,为了能够运行也改了很多地方。我使用的是VS2017,一些所需库什么的百度也都安了,但是程序运行后却不能得到正常图像,我对C语言的了解几乎为零,求各位帮助,谢谢啦下面是效果图,类似[img=https://img-bbs.csdn.net/upload/201709/07/1504779350_753325.jpg][/img][img=https://img-bbs.csdn.net/upload/201709/07/1504779370_479852.jpg][/img]rn[code=c]  /*REM Design of disk cam profile */rn#includern#includern#includern#includern#include rn#define PI 3.1415926rnvoid sds();rnvoid sdjdj();rnvoid scos();rnvoid ssin();rnvoid zbz(int);rnvoid hds();rnvoid hdjdj();rnvoid hcos();rnvoid hsin();rnvoid dral();rnvoid htl();rnfloat s[360], v[360], a[360], x[360], z[360], x1[360], z1[360];rnfloat r0, e, rr, h, d, d0, ds, d02, ds2, d03, ds3, d01, ds1, pi, p, s0, d1, d2, sn, hn, i, d3, d4, d5;rnfloat maxs, maxv, maxa, yy, ip, d0p, sd, cd, dss, dx, dy, q, ss;rnvoid ingraph();rnvoid ingraph()rnrn int gd = 0, gm, ErrorCode;rn initgraph(&gd, &gm, "");rn ErrorCode = 0;rn if (ErrorCode != 0)rn rn printf("Crahpics System Error:%s\n", "ErrorCode");rn exit(1);rn rn setbkcolor(0);rnrnint SNG(float va)rnrn if (va > 0)return 1;rn if (va == 0)return 0;rn if (va < 0)return -1;rnrnmain()rnrn maxs = 0;maxv = 0;maxa = 0;rn p = PI / 180;rn printf("Design of disk cam profile\n");rn printf("---------------------\n");rn printf("input r0=");scanf("%f", &r0);rn printf("input rr=");scanf("%f", &rr);rn printf("input e= ");scanf("%f", &e);rn printf("input h= ");scanf("%f", &h);rn printf("rise motion law sn=");scanf("%f", &sn);rn printf("input d0=");scanf("%f", &d0);rn printf("input ds=");scanf("%f", &ds);rn printf("input d01=");scanf("%f", &d01);rn printf("input ds1=");scanf("%f", &ds1);rn printf("input d02=");scanf("%f", &d02);rn printf("input ds2=");scanf("%f", &ds2);rn printf("return motion law hn=");scanf("%f", &hn);rn printf("input d03=");scanf("%f", &d03);rn printf("input ds3=");scanf("%f", &ds3);rn s0 = sqrt(r0*r0 - e*e);rn for (i = 0;i <= d0;i++)rn rn int sn = 0;rn switch (sn)rn rn case 1:rn sds();break;rn case 2:rn sdjdj();break;rn case 3:rn scos();break;rn default:rn ssin();break;rn rn zbz(i);rn rn d1 = d0 + ds;rn for (i = d0 + 1;i <= d1;i++)rn rn int i=0;rn s[i] = h;v[i] = 0;a[i] = 0;rn zbz(i);rn rn d2 = d1 + d01 + ds1;rn for (i = d1 + 1;i <= d2;i++)rn rn int i=0;rn s[i] = h+2;v[i]= 0;a[i] = 0;rn zbz(i);rn rn d3 = d2 + d02 + ds2;rn for (i = d2 + 1;i <= d3;i++)rn rn int i=0;rn s[i] = h+4;v[i] = 0;a[i] = 0;rn zbz(i);rn rn d4 = d3 + d03;rn for (i = d3 + 1;i <= d4;i++)rn rn int hn=0;rn switch (hn)rn rn case 1:rn hds();break;rn case 2:rn hdjdj();break;rn case 3:rn hcos();break;rn case 4:rn hsin();break;rn rn zbz(i);rn rn d5 = d4 + ds3;rn for (i = d4 + 1;i <= d5;i++)rn rn int i=0;rn s[i] = 0;v[i] = 0;a[i] = 0;rn zbz(i);rn rn printf("Coodinate of disk cam profile and motion law\n");rn printf("-------------------------------------\n");rn printf(" i\t x\t z\t\t x1\t z1\t s\t v\t a\n");rn for(i=0;i<=360;i=i+30)rn rn int i=0;rn printf("%7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f\n", rn i, x[i], z[i], x1[i], z1[i], s[i], v[i], a[i]);rn if (fabs(s[i]) > maxs) maxs = fabs(s[i]);rn if (fabs(v[i]) > maxv) maxv = fabs(v[i]);rn if (fabs(a[i]) > maxa) maxa = fabs(a[i]);rn rn _getch();rn ingraph();rn dral();rn _getch();rn closegraph();rn ingraph();rn htl();rn _getch();rn closegraph();rnrnvoid dral()rnrn int i;rn printf(" s");rn printf("\t\tmaxs(mm) =%f\n", maxs);rn printf(" v");rn printf("\t\tmaxv(m) =%f\n,maxv/1000");rn printf(" a");rn printf("\t\tmaxa(m) =%f\n,maxa/1000");rn printf("\n\n\n\n\n\n\n\n\n\n\n\t\t\t\t\tdlt\n\n");rn printf(" 0 90 180 ");rn printf(" 270 360\n");rn line(0, 240, 380, 240);rn line(380, 240, 373, 235);rn line(380, 240, 373, 245);rn line(10, 480, 10, 0);rn line(10, 0, 5, 7);line(10, 0, 15, 7);rn putpixel(10, 240 - s[1], 3);rn moveto(10, 240 - s[1]);rn setcolor(YELLOW);rn line(35, 10, 15, 10);rn for (i = 0;i <= 360;i++)rn lineto(i + 10, 240 - s[i] * maxs*0.4);rn putpixel(10, 240 - v[1], 4);rn moveto(10, 240 - v[1]);rn setcolor(RED);rn line(35, 25, 45, 25);rn for (i = 0;i <= 360;i++)rn lineto(i + 10, 240 - v[i] * maxv*0.4);rn putpixel(10, 240 - a[1], 14);rn moveto(10, 240 - a[1]);rn setcolor(BLUE);rn line(35, 40, 45, 40);rn for (i = 0;i <= 360;i++)rn lineto(i + 10, 240 - a[i] * maxa*0.2);rnrnvoid hcos()rnrn int i=0;rn s[i] = 0.5*(h+4)*(1 + cos(PI*(i - d3) / d03));rn v[i] = -0.5*(h+4)*PI*sin(PI*(i - d3) / d03) / (d03*p);rn a[i] = -0.5*(h+4)*PI*PI*cos(PI*(i - d3) / d03) / ((d03*p)*(d03*p));rnrnvoid hdjdj()rnrn int i = 0;rn if (i <= (d3 + d03 / 2))rn rn s[i] = (h + 4)*(1 - 2 * ((i - d3) / d03)*((i - d3) / d03));rn v[i] = -4 * (h + 4)*(i - d3)*p / ((d03*p)*(d03*p));rn a[i] = -4 * (h + 4) / ((d03*p)*(d03*p));rn rn elsern rn s[i] = 2 * (h + 4)*(d03 + d3 - i)*(d03 + d3 - i) / (d03*d03);rn v[i] = -4 * (h + 4)*(d03 + d3 - i)*p / ((d03*p)*(d03*p));rn a[i] = 4 * (h + 4) / ((d03*p)*(d03*p));rn rnrn void hds() rn rn int i=0;rn s[i] = (h + 4)*(1 - (i - d3) / d03);rn v[i] = -(h + 4) / (d03*p);rn a[i] = 0;rn rn void hsin()rn rn int i=0;rn s[i] = (h + 4)*(1 - (i - d3) / d03 + sin(2 * PI*(i - d3) / d03) / (2 * PI));rn v[i] = -(h + 4)*(1 - cos(2 * PI*(i - d3) / d03)) / (d03*p);rn a[i] = -2 * PI*(h + 4)*sin(2 * PI*(i - d3) / d03) / ((d03*p)*(d03*p));rn rn void htl()rn rn line(0, 240, 640, 240);rn line(640, 240, 633, 245);rn line(640, 240, 633, 235);rn line(320, 20, 320, 460);rn line(320, 20, 325, 27);rn line(320, 20, 315, 27);rn circle(320, 240, r0);rn circle(320, 240, 5);rn line(305, 255, 316, 244);rn line(335, 255, 324, 244);rn line(303, 255, 337, 255);rn line(305, 255, 298, 263);rn line(315, 255, 308, 263);rn line(325, 255, 318, 263);rn line(335, 255, 328, 263);rn circle(320, 240, e);rn putpixel(320 + e, 240, 3);rn int yy = 0;rn moveto(320 + e, 240);rn while (yy<240)rn rn line(320 + e, -yy + 240, 320 + e, -yy + 225);rn moveto(320 + e, -yy + 225);rn yy = yy + 20;rn if (yy>r0) lineto(320 + e, -yy + 240);rn rn line(e + 315, 40, e + 315, 90);rn line(e + 325, 40, e + 325, 90);rn line(e + 315, 50, e + 307, 60);rn line(e + 315, 60, e + 307, 70);rn line(e + 315, 70, e + 307, 80);rn line(e + 315, 80, e + 307, 90);rn line(e + 333, 40, e + 325, 50);rn line(e + 333, 50, e + 325, 60);rn line(e + 333, 60, e + 325, 70);rn line(e + 333, 70, e + 325, 80);rn putpixel(320 + x[1], 240 - z[1], 3);rn moveto(x[1] + 320, -z[1] + 240);rn for (i = 0;i<360;i++)rn rn int i=0;rn lineto(x[i] + 320, -z[i] + 240);rn circle(x[i] + 320, -z[i] + 240, rr);rn moveto(x[i] + 320, 240 - z[i]);rn int i;rn putpixel(x1[1] + 320, -z1[1] + 240, 3);rn moveto(x1[1] + 320, -z1[1] + 240);rn for (i = 0;i <= 360; i++)rn lineto(x1[i] + 320, -z1[i] + 240);rn rn void scos()rn rn int i=0;rn s[i] = 0.5*h*(1 - cos(PI*i / d0));rn v[i] = 0.5*h*PI*sin(PI*i / d0) / (d0*p);rn a[i] = 0.5*h*PI*PI*cos(PI*i / d0) / ((d0*p)*(d0*p));rn rn void sdjdj()rn rn int ip, d0p;rn ip = i*p;d0p = d0*p;rn if (i <= d0 / 2)rn rn int i=0;rn s[i] = 2 * h*(i / d0)*(i / d0);rn v[i] = 4 * h*ip / (d0p*d0p);rn a[i] = 4 * h / (d0p*d0p);rn rn elsern rn int i=0;rn s[i] = h - 2 * h*((d0 - i) / d0)*((d0 - i) / d0);rn v[i] = 4 * h*(d0 - i)*p / (d0p*d0p);rn a[i] = -4 * h / (d0p*d0p);rn rn rn void sds()rn rn int i=0;rn s[i] = h*i / d0;rn v[i] = h / (d0*p);rn a[i] = 0;rn rn void ssin()rn rn int i=0;rn s[i] = h*(i / d0 - sin(2 * PI*i / d0) / (2 * PI));rn v[i] = h*(1 - cos(2 * PI*i / d0)) / (d0*p);rn a[i] = 2 * PI*h*sin(2 * PI*i / d0) / ((d0*p)*(d0*p));rn rn void zbz(int j)rn rn ss = s0 + s[j];d = j*p;rn sd = sin(d);cd = cos(d);rn x[j] = ss*sd + e*cd;rn z[j] = ss*cd - e*sd;rn dss = v[j] - e;rn dx = dss*sd + ss*cd;rn dy = dss*cd - ss*sd;rn if (fabs(dy)>1E-10)rn rn q = atan(dx / (-dy));rn q = q - (SNG(-dy) - 1)*PI / 2;rn rn elsern rn q = PI / 2;rn q = q - (SNG(-dy) - 1)*PI / 2;rn rn x1[j] = x[j] - rr*cos(q);rn z1[j] = z[j] - rr*sin(q);rn rn[/code]
android 空指针问题
[b][i][color=#FF0000]MainActivity.java[/color][/i][/b]rnrnpublic class MainActivity extends Activity rn private ListView news_list;rn private String IMOOCURL="http://www.imooc.com/api/teacher?type=4&num=30";rnrn @Overridern protected void onCreate(Bundle savedInstanceState) rn super.onCreate(savedInstanceState);rn requestWindowFeature(Window.FEATURE_NO_TITLE);rn setContentView(R.layout.activity_main);rnrn news_list= (ListView) this.findViewById(R.id.id_newslist);rn new NewsThread().execute(IMOOCURL);rn rnrn class NewsThread extends AsyncTask>rnrn @Overridern protected List doInBackground(String... params) rn List alldata= getJSONDate(params[0]);rn return alldata;rn rnrn @Overridern protected void onPostExecute(List newsBeans) rn super.onPostExecute(newsBeans);rn ListAdapter adapter = new ListAdapter(MainActivity.this,newsBeans,news_list);rn news_list.setAdapter(adapter);rn rnrn //从网站解析得到数据rn private List getJSONDate(String param)rn List alldata = new ArrayList<>();rn String result="";rn try rn InputStream is = new URL(param).openStream();rn InputStreamReader isr = new InputStreamReader(is,"UTF-8");rn BufferedReader br = new BufferedReader(isr);rn String line="";rn while ((line=br.readLine())!=null)rn result=result+line;rn rn JSONObject JSON_object = new JSONObject(result);rnrn JSONArray JSON_array =JSON_object.getJSONArray("data");rn for (int i=0;i alldata;rn private LayoutInflater inflater;rn private Imageloader imageloader;rnrn private int startData; //第一个可见项rn private int endData; //最后一个可见项rn private String URLS[]; //加载所有图片的URLrnrn private boolean isFirst; //是否是第一次加载rn public ListAdapter(Context context,List list,ListView listView)rn this.alldata=list;rn inflater =LayoutInflater.from(context);rn imageloader=new Imageloader(listView);rnrn URLS = new String[list.size()];rn for (int i=0;i0)rn imageloader.loadImages(startData,endData,URLS);rn isFirst=false;rn rn rn
相关热词 c# stream 复制 android c# c#监测窗口句柄 c# md5 引用 c# 判断tabtip 自己写个浏览器程序c# c# 字符串变成整数数组 c#语言编程写出一个方法 c# 转盘抽奖 c#选中treeview