新手求大神帮助。仿照window7写的图片浏览器,运行一直显示空指针异常,求帮助,谢谢

package com.xpc.picture;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.FrameLayout.LayoutParams;
import android.widget.GridView;
import android.widget.ImageSwitcher;
import android.widget.ImageView;
import android.widget.ViewSwitcher.ViewFactory;

/*
*一直都是空指针异常,求大神指点一点
*/

public class MainActivity extends Activity {

private int[] imageId = new int[]{R.drawable.a,R.drawable.b,R.drawable.c,
        R.drawable.e,R.drawable.f,R.drawable.g,R.drawable.h,
        R.drawable.i};//定义并初始化保存图片IDde 数组
private ImageSwitcher imageSwitcher;  //申明一个图像切换器对象

GridView gridview = (GridView) findViewById(R.id.gridview1);

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    imageSwitcher = (ImageSwitcher) findViewById(R.id.imageSwitcher1);
    imageSwitcher.setInAnimation(AnimationUtils.loadAnimation(this,android.R.anim.fade_in));//设置淡入动画
    imageSwitcher.setOutAnimation(AnimationUtils.loadAnimation(this,android.R.anim.fade_out));//淡出效果
    imageSwitcher.setFactory(new ViewFactory() {

        @Override
        public View makeView() {
            // TODO Auto-generated method stub
            ImageView imageView = new ImageView(MainActivity.this);//实例化一个ImageView类的对象
            imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
            imageView.setLayoutParams(new ImageSwitcher.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT));//设置保持纵横比居中缩放图像
            //是否导包错误???这是要导什么包,太多了

            return imageView;
        }
    });     
    imageSwitcher.setImageResource(imageId[6]);

    BaseAdapter adapter = new BaseAdapter(){

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

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

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

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            // TODO Auto-generated method stub
            ImageView imageview;
            if(convertView==null){
                imageview = new ImageView(MainActivity.this);
                imageview.setAdjustViewBounds(true);
                imageview.setMaxWidth(150);//设置长度宽度
                imageview.setMaxHeight(113);
                imageview.setPadding(5,5, 5,5);//设置内边距
            }else{
                imageview=(ImageView) convertView;
            }
            imageview.setImageResource(imageId[position]);//设置要显示的图片
            return imageview;
        }

    };

    gridview.setAdapter(adapter);
    gridview.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view,
                int position, long id) {
            // TODO Auto-generated method stub
            imageSwitcher.setImageResource(imageId[position]);

        }
    });
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

}

布局文件
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

<GridView 
    android:id="@+id/gridview1"
    android:layout_height="match_parent"
    android:layout_width="640dp"
    android:layout_marginTop="10dp"
    android:horizontalSpacing="3dp"
    android:verticalSpacing="3dp"
    android:numColumns="4"
    />
<ImageSwitcher 
    android:id="@+id/imageSwitcher1"
    android:padding="20dp"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    />

3个回答

GridView gridview = (GridView) findViewById(R.id.gridview1);应该写在setContentView(R.layout.activity_main);后面的

GridView gridview = (GridView) findViewById(R.id.gridview1);怎么写在了onCreate的外面

谢谢,已经解决了。。。。。。。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
新手求大神帮助!
求大神帮忙把这段程序改到可以在C++程序运行,我才学不久。rnrnrn#define N 30 rn#include rn#include rnstruct student rnchar name[20]; char phone[50]; char stunum[15]; char dorm[20];stu[N];rnrnvoid printf_face()rn printf("\n\t姓名\t电话号码\t学号\t宿舍号\n"); rnrnvoid printf_one(int i)rn printf("\t%s\t%s\t%s\t%s\n",stu[i].name,stu[i].phone,stu[i].stunum,stu[i].dorm); rnrnvoid printf_n(int n)rn int j;rn for(j=0;j\n\n 1).姓名 2).电话号码 3).学号 4).宿舍号 5).所有数据 6).取消并返回");rn rn printf("请选择?: [ ]\b\b");rn scanf("%d",&c);rn if(c>6||c<1) puts("\nChoose error! Please again!"); getchar();rn while(c>6||c<1);rn dorn switch(c)rn case 1: printf("name:"); scanf("%s",stu[i].name); break;rn case 2: printf("phone:"); scanf("%s",stu[i].phone); break;rn case 3: printf("stunum:"); scanf("%s",stu[i].stunum); break;rn case 4: printf("dorm:"); scanf("%s",stu[i].dorm); break;rn case 5: input(i); break;rn case 6: menu(); rn rn puts("\nNow:\n");rn printf_face(); printf_one(i);rn printf("\n确定?\n\n\t1).是 2).不,重新修改 3).返回不保存 [ ]\b\b");rn scanf("%d",&w1);rn while(w1==2);rn return(w1);rnrnrnvoid input(int i)rn printf_face(); printf("\t");rn scanf("%s\t%s\t%s\t%s",stu[i].name,stu[i].phone,stu[i].stunum,stu[i].dorm); rnrnvoid save(int n)rn FILE *fp; int i;rn if((fp=fopen("file","wb"))==NULL)rn printf("\nCan not open file\n");rn exit(0);rn rn for(i=0;i6)rn w1=1;getchar();rn else w1=0;rnrn while(w1==1);rn switch(n)rn; rn case 1: enter(); break;rn case 2: add(); break;rn case 3: delete(); break;rn case 4: modify(); break;rn case 5: search(); break;rn case 6: exit(0); rn rnrnrnvoid enter() rn int i,n;rn printf("How many student(0-%d)?:",N-1);rn scanf("%d",&n);rn printf("请输入数据:\n");rn for(i=0;i2) printf("输入错误!请重新输入!\n"); w2=1;rn while(w2==1);rn if(w1==1)rn dorn k=-1; rn dorn printf("\n\nEnter name that tou want to search!\nName:");rn scanf("%s",s.name);rn for(i=0;i
新手 求大神帮助
点击时间边上的按钮,能够查询出该符合条件的数据,并且显示在本页面上,我试过ajax ,但是没有成功,学的时间不长,希望大家能帮助一下。谢谢了rn这是未处理的代码如下:[code=php]rnrnrn rn rn rn rn rn rnrnrn$totlePage)rn rn $page = $totlePage;rn rn rnrn $start = ($page-1) * $perPageNum;rn rn?>rnrn 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 rn rn rn rn rn rn rnrnrn rn rn rn rnrnrn rn rn rn rn rn rn rn 摄影团列表rn rn rn rn rn rnrn rn rn IDrn 客户姓名rn 摄影特长rn 联系电话rn 参团统计rn 今后参团意向rn 录入时间rn 录入操作员rn 查看详细信息rnrnrn rn rn rn rn rn rn rn rn rn rn rn 查看rn 回访 rn rn rnrn rn rnrn rn rn rn 首页rn 上一页rn rn首页rn上一页rnrn 下一页rn 尾页rnrn下一页rn尾页rnrnrnrn rn rn共有记录条,当前页,共有页 rnrnrnrnrnrn[/code]rn界面图片:[img=https://img-bbs.csdn.net/upload/201704/24/1493002788_359747.png][/img]rn这是ajax的处理页面的代码 ,也是从网上刚学的 不是太会rn[code=php] [/code]
求帮助,,谢谢大神
简单的编写银色滚球的C++的程序怎么编写啊!!谢谢!
新手求帮助,谢谢
#includern#define SQ(y) ((y)*(y))rnmain()rnrn int i=1;rn while(i<=5)rn printf("%d\n",SQ(i++));rnrnrnrnrnrn求问:为什么运行结果是1 9 25而不是1 4 9 16 25啊,求详解,谢谢
空指针异常求帮助
出错提示[code=java]java.lang.NullPointerExceptionrn at com.tchManage.dao.PostDAO.findAllPost(PostDAO.java:39)rn at com.tchManage.servlet.PostController.findAll(PostController.java:131)rn at com.tchManage.servlet.PostController.doPost(PostController.java:40)rn at com.tchManage.servlet.PostController.doGet(PostController.java:147)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)rn at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)rn at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)rn at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)rn at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)rn at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)rn at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1822)rn at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)rn at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)rn at java.lang.Thread.run(Thread.java:619)rn[/code]rnrnrncom.tchManage.dao.PostDAO.javarn[code=java]public List findAllPost(int currentPage) throws SQLException,ClassNotFoundExceptionrn tryrn ResultSet rs=pl.pageList(5,"userinfo",currentPage,"desc","id");[color=#FF0000](39)[/color]rn System.out.println(rs);rn rs.beforeFirst();rn List list=new ArrayList();rn rn while(rs.next())rn Post u=new Post();rn u.setId(rs.getInt("id"));rn u.setTitle(rs.getString("title"));rn u.setContent(rs.getString("content"));rn u.setTime(rs.getString("time"));rn rn list.add(u); rn rn return list;rn rn catch(Exception e)rn e.printStackTrace();rn [/code]rnrncom.tchManage.servlet.PostController.javarn[code=java]//查找所有公告rn private void findAll(HttpServletRequest request,rn HttpServletResponse response) rn tryrn //request.setAttribute("pageinfo",postdao.pageSize());rn //String currpage=request.getParameter("currentPage");rn rn int currentPage=1;rn //if(currpage!=null)rn // currentPage=Integer.parseInt(currpage);rn // rn List list = new ArrayList();rn list = postdao.findAllPost(currentPage);rn request.setAttribute("findAll", list);rn RequestDispatcher rd = request.getRequestDispatcher("index.jsp");rn rd.forward(request, response);rn rn catch(Exception e)rn e.printStackTrace();rn rn rn [/code]rnrnrnPageList.java pageList()分页方法rn[code=java]public ResultSet pageList(int pagesize, String tablename, int currentePage,rn String sort, String sortBy) throws ClassNotFoundException rn //ResultSet rs=null;rn try rn new DBConnection();rn Connection conn=DBConnection.getConnection();rn //Connection conn = DBConnection.getConnection();rn String sql = "select * from " + tablename;rn System.out.println(sql);rn PreparedStatement psmt=conn.prepareStatement(sql);rn ResultSet rs = psmt.executeQuery();rn System.out.println(rs);rn if (currentePage == 1) rnrn String getRs = "select * from "rn + tablename + " where id >0 order by " + sortBy + " "rn + sort+" limit "+ pagesize ;rn ResultSet pageRs = psmt.executeQuery(getRs);rn System.out.println("sss"+pageRs);rn return pageRs;rn else rn rs.absolute(pagesize * (currentePage - 1));rn int lastid = rs.getInt("id");rn String getRs = "select * from "rn + tablename + " where id>" + lastid + " order by "rn + sortBy + " " + sort+" limit "+ pagesize;rn ResultSet pageRs = psmt.executeQuery(getRs);rn System.out.println("ss"+pageRs);rn return pageRs;rn rnrn catch (Exception e) rn e.printStackTrace();rn rn return null;rn [/code]rnrnrnindex.jsp中显示的部分rn[code=java]rn rn rn rn $post.titlernrn rnrn $post.timern rn $post.contentrnrnrn[/code]rnrn调试第一步rn[img=http://img.my.csdn.net/uploads/201212/28/1356690915_8155.jpg][/img]rnrn调试第二步直接跳到catchrn[img=http://img.my.csdn.net/uploads/201212/28/1356690976_8477.jpg][/img]rnrn大家帮帮忙吧!~很神奇的bug。
java新手求大神帮助~~
这个是为什么?输入类型不对吗?为什么一次出现两个命令?[img=https://img-bbs.csdn.net/upload/201610/23/1477192623_608842.png][/img][img=https://img-bbs.csdn.net/upload/201610/23/1477192639_39621.png][/img][img=https://img-bbs.csdn.net/upload/201610/23/1477192658_899958.png][/img]
新手菜鸟,求大神帮助
用SoundPlayer类 然后写的下面这个代码,为什么只有b这个能发出声音,a发不出声音(a、b单独都能播放出来)rnrnprivate void button1_Click(object sender, EventArgs e)rn rn rn rn SoundPlayer a = new SoundPlayer(Properties.Resources.a);rn a.Play();rn rn SoundPlayer b = new SoundPlayer(Properties.Resources.b);rn b.Play();rn rnrn rn换成这个也不行。。。。rnprivate void button1_Click(object sender, EventArgs e)rn rn rn for(int m=0;m<2;m++)rn rn if (m == 0)rn rn SoundPlayer a = new SoundPlayer(Properties.Resources.a);rn a.Play();rn rn if (m == 1)rn rn SoundPlayer b = new SoundPlayer(Properties.Resources.b);rn b.Play();rn rnrn rn rn求大神说说哪出问题了,应该怎么修改
新手小白求大神帮助
最近和学长一起做stm32f429zgt6开发板,做完了,求大神给一个stm32F429驱动2.8寸spi触摸屏的测试例程,屏幕如下 ,控制芯片是Xpt2046,求有玩f429的大神带飞
急求大神帮助!谢谢!
怎样用ooencv来实现识别沙滩上的人数,获得他们的体重?
新手求帮助,谢谢啦
我以前并不是学计算机的,只接触过一点点C,rn现在转专业以后上嵌入式系统课有很多东西听不懂rn请教一下spawn(),yield(),lock/unlock,mutex(),setjmp/longjmprn这几个语句的用法rn我想自己找点基础的教材看看,请大家帮忙推荐一下好吗rn小弟在此谢谢了
JBUILDER空指针异常,急求帮助
用JBUILDER2005做个小的聊天软件,但是却总是出现java.lang.NullPointerException异常,网上有高手说debug以下,可小弟初学,不懂怎样debug,哪位高人能否帮忙DEBUG以下,找出错误,感激不尽!rnrnrnrnrnpackage simpletalk;rnrnimport java.awt.*;rnimport javax.swing.*;rnimport com.borland.jbcl.layout.XYLayout;rnimport com.borland.jbcl.layout.*;rnimport java.net.*;rnimport java.awt.event.ActionEvent;rnimport java.awt.event.ActionListener;rnrn/**rn * Title: rn *rn * Description: rn *rn * Copyright: Copyright (c) 2007rn *rn * Company: rn *rn * @author not attributablern * @version 1.0rn */rnpublic class Frame1rn extends JFrame rn JPanel contentPane;rn XYLayout xYLayout1 = new XYLayout();rn JButton jButton1 = new JButton();rn JLabel jLabel1 = new JLabel();rn JLabel jLabel2 = new JLabel();rn JScrollPane jScrollPane1 = new JScrollPane();rn JTextArea jTextArea1 = new JTextArea();rn XYLayout xYLayout2 = new XYLayout();rn JScrollPane jScrollPane2 = new JScrollPane();rn JTextArea jTextArea2 = new JTextArea();rn DatagramPacket sendPacket,receivePacket;rn DatagramSocket sender,receiver;rn JTextField jTextField1 = new JTextField();rn public Frame1() rn try rn setDefaultCloseOperation(EXIT_ON_CLOSE);rn jbInit();rn startChat();rn rn catch (Exception exception) rn exception.printStackTrace();rn rn rnrn /**rn * Component initialization.rn *rn * @throws java.lang.Exceptionrn */rn private void jbInit() throws Exception rn contentPane = (JPanel) getContentPane();rn contentPane.setLayout(xYLayout2);rn setSize(new Dimension(400, 300));rn setTitle("Frame Title");rn jButton1.setText("发送");rn jButton1.addActionListener(new Frame1_jButton1_actionAdapter(this));rn jLabel1.setText("好友");rn jLabel2.setText("消息");rn jTextField1.setText("jTextField1");rn jTextArea2.setText("按当地");rn jTextArea1.setText("达到");rn contentPane.add(jLabel2, new XYConstraints(24, 232, -1, -1));rn contentPane.add(jLabel1, new XYConstraints(83, 15, -1, -1));rn contentPane.add(jButton1, new XYConstraints(297, 231, -1, -1));rn jScrollPane2.getViewport().add(jTextArea2);rnrn contentPane.add(jScrollPane1, new XYConstraints(108, 71, 176, 69));rn contentPane.add(jTextField1, new XYConstraints(4, 146, -1, -1));rn jScrollPane1.getViewport().add(jTextArea1);rn contentPane.add(jScrollPane2, new XYConstraints(69, 196, 179, 87));rn rn public void startChat()rn rn tryrn sender=new DatagramSocket();rn receiver=new DatagramSocket(6666);rn receiver1 r=new receiver1();rn Thread t=new Thread(r);rn t.start();rnrn catch(Exception e)rn JOptionPane.showMessageDialog(this,"连接错误"+e.toString());rn rnrn public void jButton1_actionPerformed(ActionEvent e) rn tryString dest=jTextField1.getText();rn String message=jTextArea2.getText();rn if(!dest.equals(""))rn rnrnrn jTextArea1.append("\n到"+receivePacket.getAddress()+":"+message);rn byte data[]=message.getBytes();rn sendPacket=new DatagramPacket(data,data.length,InetAddressrn .getByName(dest),7777);rnrn sender.send(sendPacket);rn rnrn rn catch(Exception ue)rnrn rnrn class receiver1 implements Runnablern public void run()rn rn while(true)rn rn tryrn rn byte mess[]=new byte[200];rn receivePacket=new DatagramPacket(mess,mess.length);rn receiver.receive(receivePacket);rn jTextArea1.append("\n来自"+receivePacket.getAddress()+":");rn byte data[]=receivePacket.getData();rn String message=new String(data);rn jTextArea1.append(message);rnrn rn catch(Exception e)rn rn rn rnrnrnrnclass Frame1_jButton1_actionAdapterrn implements ActionListener rn private Frame1 adaptee;rn Frame1_jButton1_actionAdapter(Frame1 adaptee) rn this.adaptee = adaptee;rn rnrn public void actionPerformed(ActionEvent e) rn adaptee.jButton1_actionPerformed(e);rn rnrn
setsockopt一直出错,求大神帮助,,,,,,,,,,,
struct ip_mreq mcast;rnmcast.imr_multiaddr.s_addr = dwMulticastGroup;rnmcast.imr_interface.s_addr = dwInterface;rnsetsockopt(sockM,IPPROTO_IP,IP_ADD_MEMBERSHIP,(char *)&mcast,sizeof(mcast));rnWSAGetLastError()结果是10042.
求帮助,找不到哪个空指针异常。。。。
[color=#FF0000]下面的代码报错提示为空指针异常,但是没有找到,请大家帮忙看下~[/color][color=#FF0000][/color]rnrnpackage com.googlemap;rnrnimport android.content.Context;rnimport android.content.Intent;rnimport android.content.SharedPreferences;rnimport android.content.res.Resources;rnimport android.database.Cursor;rnimport android.graphics.Canvas;rnimport android.graphics.Paint;rnimport android.graphics.Point;rnimport android.graphics.RectF;rnimport android.graphics.Paint.Style;rnimport android.location.Location;rnimport android.location.LocationListener;rnimport android.location.LocationManager;rnimport android.os.Bundle;rnimport android.util.Log;rnimport android.view.KeyEvent;rnimport android.view.Menu;rnimport android.view.MenuItem;rnimport android.view.View;rnimport android.view.View.OnClickListener;rnimport android.widget.Button;rnimport android.widget.Toast;rnrnimport com.google.android.maps.GeoPoint;rnimport com.google.android.maps.MapActivity;rnimport com.google.android.maps.MapController;rnimport com.google.android.maps.MapView;rnimport com.google.android.maps.MyLocationOverlay;rnimport com.google.android.maps.Overlay;rnimport com.googlemap.R;rnrnpublic class ShowTrack extends MapActivity rn // 定义菜单需要的常量rn private static final int MENU_NEW = Menu.FIRST + 1;rn private static final int MENU_CON = MENU_NEW + 1;rn private static final int MENU_DEL = MENU_CON + 1;rn private static final int MENU_MAIN = MENU_DEL + 1;rnrn private TrackDbAdapter mDbHelper;rn private LocateDbAdapter mlcDbHelper;rnrn private static final String TAG = "ShowTrack";rn private static MapView mMapView;rn private MapController mc;rnrn protected MyLocationOverlay mOverlayController;rn private Button mZin;rn private Button mZout;rn private Button mPanN;rn private Button mPanE;rn private Button mPanW;rn private Button mPanS;rn private Button mGps;rn private Button mSat;rn private Button mTraffic;rn private Button mStreetview;rn private String mDefCaption = "";rn private GeoPoint mDefPoint;rnrn private LocationManager lm;rn private LocationListener locationListener;rnrn private int track_id;rn private Long rowId;rnrn /** Called when the activity is first created. */rn public void onCreate(Bundle icicle) rn super.onCreate(icicle);rn setContentView(R.layout.show_track);rn findViews();rn centerOnGPSPosition();rn revArgs();rn // ///////////////rn //mDbHelper = new TrackDbAdapter(this);rn //mDbHelper.open();rnrn //mlcDbHelper = Track.getDbHelp();rn //new LocateDbAdapter(this);rn //mlcDbHelper.open();rnrn paintLocates();rn startTrackService();rn rnrn private void startTrackService() rn Intent i = new Intent("com.iceskysl.iTracks.START_TRACK_SERVICE");rn i.putExtra(LocateDbAdapter.TRACKID, track_id);rn startService(i); rn rn rn private void stopTrackService() rn stopService(new Intent("com.iceskysl.iTracks.START_TRACK_SERVICE")); rn rnrn private void paintLocates() rn mlcDbHelper = new LocateDbAdapter(this);rn mlcDbHelper.open();rn Cursor mLocatesCursor = mlcDbHelper.getTrackAllLocates(track_id);rn startManagingCursor(mLocatesCursor);rn Resources resources = getResources();rn Overlay overlays = new LocateOverLay(resourcesrn .getDrawable(R.drawable.icon), mLocatesCursor);rn mMapView.getOverlays().add(overlays);rn mlcDbHelper.close();rn rnrn private void revArgs() rn Log.d(TAG, "revArgs.");rn Bundle extras = getIntent().getExtras();rn if (extras != null) rn String name = extras.getString(TrackDbAdapter.NAME);rn //String desc = extras.getString(TrackDbAdapter.DESC);rn rowId = extras.getLong(TrackDbAdapter.KEY_ROWID);rn track_id = rowId.intValue();rn Log.d(TAG, "rowId=" + rowId);rn if (name != null) rn setTitle(name);rn rn rn rnrn protected boolean isRouteDisplayed() rn // TODO Auto-generated method stubrn return false;rn rnrn private void findViews() rn Log.d(TAG, "find Views");rn // Get the map view from resource filern mMapView = (MapView) findViewById(R.id.mv);rn mc = mMapView.getController();rnrn SharedPreferences settings = getSharedPreferences(Setting.SETTING_INFOS, 0);rn String setting_gps = settings.getString(Setting.SETTING_MAP, "10");rn mc.setZoom(Integer.parseInt(setting_gps));rnrn // Set up the button for "Pan East"rn mPanE = (Button) findViewById(R.id.sat);rn mPanE.setOnClickListener(new OnClickListener() rn // @Overridern public void onClick(View arg0) rn panEast();rn rn );rn // Set up the button for "Zoom In"rn mZin = (Button) findViewById(R.id.zin);rn mZin.setOnClickListener(new OnClickListener() rn // @Overridern public void onClick(View arg0) rn zoomIn();rn rn );rn // Set up the button for "Zoom Out"rn mZout = (Button) findViewById(R.id.zout);rn mZout.setOnClickListener(new OnClickListener() rn // @Overridern public void onClick(View arg0) rn zoomOut();rn rn );rn // Set up the button for "Pan North"rn mPanN = (Button) findViewById(R.id.pann);rn mPanN.setOnClickListener(new OnClickListener() rn // @Overridern public void onClick(View arg0) rn panNorth();rn rn );rnrn // Set up the button for "Pan East"rn mPanE = (Button) findViewById(R.id.pane);rn mPanE.setOnClickListener(new OnClickListener() rn // @Overridern public void onClick(View arg0) rn panEast();rn rn );rnrn // Set up the button for "Pan West"rn mPanW = (Button) findViewById(R.id.panw);rn mPanW.setOnClickListener(new OnClickListener() rn // @Overridern public void onClick(View arg0) rn panWest();rn rn );rn // Set up the button for "Pan South"rn mPanS = (Button) findViewById(R.id.pans);rn mPanS.setOnClickListener(new OnClickListener() rn // @Overridern public void onClick(View arg0) rn panSouth();rn rn );rnrn // Set up the button for "GPS"rn mGps = (Button) findViewById(R.id.gps);rn mGps.setOnClickListener(new OnClickListener() rn // @Overridern public void onClick(View arg0) rn centerOnGPSPosition();rn rn );rn // Set up the button for "Satellite toggle"rn mSat = (Button) findViewById(R.id.sat);rn mSat.setOnClickListener(new OnClickListener() rn // @Overridern public void onClick(View arg0) rn toggleSatellite();rn rn );rnrn // Set up the button for "Traffic toggle"rn mTraffic = (Button) findViewById(R.id.traffic);rn mTraffic.setOnClickListener(new OnClickListener() rn // @Overridern public void onClick(View arg0) rn toggleTraffic();rn rn );rnrn
求取星期几!!!求大神帮助
![图片说明](https://img-ask.csdn.net/upload/201607/01/1467345462_777440.png)nn选取的年份 来求星期几 n![图片说明](https://img-ask.csdn.net/upload/201607/01/1467345509_970629.png)n这张图片有说明 我吧我的js贴出来 你们帮我看看 那不对 谢谢 nn```n function tuaisuan()n var shijian = $("#EntTime32").val();n var arr = shijian.split('-');n n var nian = parseFloat(arr[0]);n var yue = parseFloat(arr[1]);n var ri = parseFloat(arr[2]);n var shiji = parseFloat(arr[0].substring(0,2));n var nian1 = parseFloat(arr[0].substring(2));n n //求星期n if(yue<3)n var yue1=yue+12n /*var xingqi = parseFloat(nian1+[nian1/4]+[shiji/4]-2*shiji+[26*(yue1+1)/10]+ri-1);n alert(xingqi);n 不知道为什么结果不对 我只好给他分段计算了n */n var s1 = nian1/4n var s2 = shiji/4n var s3 = 2*shijin var s4 = 26*(yue1+1)/10n var s5 = parseInt(nian1+s1+s2-s3+s4+ri-1)n alert(s4);alert(s5);n n elsen //var xingqi = parseInt(nian1+[nian1/4]+[shiji/4]-2*shiji+[26*(yue+1)/10]+ri-1);alert(xingqi); 不知道为什么结果不对 我只好给他分段计算了n var s1 = nian1/4n var s2 = shiji/4n var s3 = 2*shijin var s4 = 26*(yue+1)/10n var s5 = parseInt(nian1+s1+s2-s3+s4+ri-1)n /*alert(s1);alert(s2);alert(s3);*/alert(s4);alert(s5);n n n```nn
求高手,求大神帮助~
我要做个库存管理系统,代码我基本已经编写完了,但是运行之后,数据显示不了,我估计问题是出在文件的读写上。rn改了很久都没有成效啊。。。伤心~有没有谁可以帮忙解决一下,修改一下代码的,我的QQ549140601~rn求帮助啊。。。谢谢啦
求帮助。求帮助
接收一串字符串,格式像这样的(key=value|key=value||||)key 代表Field的name,value代表set进Object中的值,将他装换成一个Object对象,调用setter方法为其赋值,我用下面的方法调用method.invoke(obj, obj..);测试的时候用的其中一个Bean类Student。Student里面有很多Filed,怎么把value(String)转换invoke方法的第2个参数的类型啊,是像我下面那样一个一个判断吗,还是有别的方法啊。大家帮帮忙=。= 谢谢……^^rnrn[code=java]rnpackage com.ytbysj.util;rnrnimport java.lang.reflect.InvocationTargetException;rnimport java.lang.reflect.Method;rnimport java.util.HashMap;rnimport java.util.Iterator;rnimport java.util.Map;rnimport java.util.StringTokenizer;rnimport java.util.Map.Entry;rnrnimport com.ytbysj.beans.Student;rnimport com.ytbysj.exception.FooException;rnrn/**rn * Message Handler类rn * @author haniyaseyorn *rn */rnpublic class MessageHandler rn rn /**rn * 将message转换成Map对象rn * @param message like:key=value|key=value||||rn * @return 通过message转换成的MAP key=valuern */ rn public static Map messageHandler(String message)rn //如果message=null则抛出异常rn if(message == null) throw new FooException("MessageHandler messageHandler(String message) message=null");rn //简单判断message的格式rn if(message.indexOf("|") == -1) throw new FooException("MessageHandler messageHandler(String message) message do not contains \"|\"");rn if(message.indexOf("=") == -1) throw new FooException("MessageHandler messageHandler(String message) message do not contains \"=\"");rn rn //定义Map对象rn Map map = new HashMap();rn rn //定义StringTokenizer对象 并指定"|"为分隔符rn StringTokenizer stken = new StringTokenizer(message, "|");rn rn /*rn * 循环StringTokenizer中的对象 并复制到Map中rn */rn while (stken.hasMoreTokens()) rn String[] temp = stken.nextToken().split("=");rn map.put(temp[0], temp[1]);rn rn return map;rn rn rn /**rn * 根据给定的message和Class构造一个?对象rn * @param message like:key=value|key=value||||||rn * @param clazz ?的Class对象rn * @return clazz.newInstance()rn */rn public static Object getObject(String message, Class clazz)rn //获取Maprn Map map = messageHandler(message);rn //判断Map是否为空rn if(map.isEmpty()) throw new FooException("MessageHandler getObject(String message, Class clazz) map is empty");rn rn Object obj = null;rn try rn obj = clazz.newInstance();rn Iterator> ite = map.entrySet().iterator();rn while(ite.hasNext())rn Entry entry = ite.next();rn //取出每一个key valuern String item_name = entry.getKey().trim();rn String value = entry.getValue().trim();rn //构造方法名rn String methodName = "set" + String.valueOf(item_name.charAt(0)).toUpperCase() + item_name.substring(1);rn //获取Field的类型rn Class type = clazz.getDeclaredField(item_name).getType();rnSystem.out.println(methodName + "," + value + "," +type.getName());rn //获取Method对象rn Method method = clazz.getDeclaredMethod(methodName, type);rn rn //判断Field类型rn if(type == value.getClass())rn method.invoke(obj, value);rn else if(type == int.class)rn method.invoke(obj, Integer.parseInt(value));rn //..如果在这里接着判断有很多不方便的地方-。-rn rn catch (InstantiationException e) rn e.printStackTrace();rn catch (IllegalAccessException e) rn e.printStackTrace();rn catch (SecurityException e) rn e.printStackTrace();rn catch (NoSuchFieldException e) rn e.printStackTrace();rn catch (NoSuchMethodException e) rn e.printStackTrace();rn catch (IllegalArgumentException e) rn e.printStackTrace();rn catch (InvocationTargetException e) rn e.printStackTrace();rn rn return obj;rn rn rn public static void main(String[] args) rn String message = "student_no=0810024103|password= |username=叶婷|sex=男" +rn "|moblie=12296736137|native_place=重庆|college= |tie=软件工程|stuclass=09级2班|limits=3";rn System.out.println(getObject(message,Student.class));rn rnrn[/code]
求帮助!!!求帮助!!!
小弟用的是BCB 6.0,最近要开发SFTP,不知道有没 sftp的控件。小弟刚用bcb.忘大家说的详细点。谢谢!!rn
求大神帮助
求大神帮助 运行软件时出现以下问题,求大神解决。 模块“vcl50.bpl”中地址400d625e处的访问冲突。地址读数 access violation at address 400d625e in module ‘vcl50.bpl’. read of address 00000004 ...
求各位大神帮助
求解:1.oracle中可以编写sql语句建立本地文件夹吗。rn 2.oracle中怎么遍历读取指定路径下所有的图片文件并插入到数据库(根目录确定,查询包含根目录下的所有图片)。rn求脚本解决。
求大神帮助!
有一个文件shop.dat,在该文件中以二进制方式存放了50个用于表示超市商品销rn售记录的结构体类型数据。结构体的声明如下:rnstruct Salesrnrn int ID;//商品编码rn char name[30];//商品名称rn int num;//商品数量rn float price;//商品单价rnrn编写一个函数,将shop.dat 文件中的数据读出,并且构建1 个商品销售记录数组A;rn编写一个函数,删除上述所生成数组A 中单价小于4000 元的商品销售记录;rn编写一个函数,将经过上述处理的数组A 按照商品编码进行递增排序,并rn将排序后的全部结果显示在屏幕上,每种商品的数据占一行,显示格式为:rn111 IPad2 2 4688.00rn122 Iphone4S 3 5899.00rnrn求大神帮忙实习简单的代码!
大神们。。求帮助
怎么判断一个stringrn为数字rn包括中文的rn一千八百四十二或者壹仟贰佰或者15687rn这样子rn rn正则可以吗。谁可以帮忙写个。。有点迷糊。
求大神帮助 第一次
[img=https://img-bbs.csdn.net/upload/201612/14/1481719652_459471.jpg][/img][img=https://img-bbs.csdn.net/upload/201612/14/1481719659_192480.png][/img]怎么改成全屏背景
求大神帮助啊
用VFP编程序,定义一个自由表作为临时表,运行程序的时会在表中临时添加数据,程序运行完成后表中数据会被清除掉,程序在VFP中运行完好,但是编译之后脱离VFP环境运行时提示说这个临时表是以只读模式打开,不能添加数据,程序中打开数据表是以独占模式打开的,求解决方法,求帮助,急!只有20分了,不要嫌少,谢谢
大神,求帮助
我做了一个窗体,想把数据输入到ACCESS中,怎么写代码啊[img=https://img-bbs.csdn.net/upload/201512/27/1451228303_584294.png][/img]
求大神帮助。
1.1题目的内容与要求rn内容:设计一个简单的字母连连看游戏软件。rn要求:rn1)程序运行时在屏幕上随机显示3*3的字母组合;rn2)该字母组合8个是成对儿出现,也就是4个不同的字母,不成对儿的那个字母要与出现的其他字母不同;rn3)3*3位置按行计数,分别1~9,消除某一对儿时必须是在键盘上按对了两个相同字母所在的位置;rn4)若按到不成对儿那个字母所在的位置,游戏结束。若4对儿已经消除,则提示游戏过关,恭喜用户;否则提示闯关失败。
求qt大神帮助
我想写一个简单的记账软件,现在遇到了问题,布置好界面后,想要获得QLineEdit中用户输入的int数据应该怎么做,想要保存这个数据怎么做。。。。qt小白,这是作业但是是自学qt
求大神帮助!!!!
如何继承Textview并把他的属性包装在一个属性中进行统一调用
求大神帮助!!!!!!!!!!
现在公司要求设计一个智能ai的实验项目主要是实现简单的智能语音交互平台需要软硬件的设计,就是说都需要哪些硬件,需要开发哪些软件系统?我现在的认为就是:     硬件:需要一个pc机,麦克风,用来获取语音输入(或者直接使用一个移动设备)     软件:          1、交互界面,主要用于智能系统唤醒、关闭等服务          2、语音分析系统,用于对输入的语音预处理,获取语音,降噪,增强音...
大神求帮助。。
[img=https://img-bbs.csdn.net/upload/201501/16/1421370502_883936.jpeg][/img]rnrn请帮忙分析一下什么原因。。。
求大神帮助!!
编写了一套手机端网站,编写了内容后发现偶尔会有个别字体出现乱码的现象,都是些笔画较多,生僻字,但是同一页面内,该字有的乱码,有的不乱码,其他页面内该字体也不会乱码。一直没找到原因,求大神指点,感谢!!!
求大神帮助下
#include rn#include rnusing namespace std;rnrnlong b2ten (char *a,int b)//输入一个b进制的数,输出该数的十进制的数值rn int i,temp=0;rn int len=strlen(a);rn for (i=0;i=b)rn return -1;rn temp*=b;rn temp+=a[i]-'0';rn rn return (long)temp;rnrnrnint main()rnint b;rn rn char a1[8],a2[8],a3[3];rn rn long b1,b2,b3;rn cout <<"please input three numbers"<>*a1>>*a2>>*a3;rn for (b=2;b<16;b++)rn b1=b2ten(a1,b);rn b2=b2ten(a2,b);rn b3=b2ten(a3,b);rn if(b1==-1||b2==-1||b3==-1)rn cout<<"there is no answer !fuck!"<
求大神帮助多表查询
请问:rn有2个表,一个是全员信息表(人员编号,姓名,性别,身份证号,子女数),表中有男有女,只有女性的子女数字段是有效的,男性的话这个字段没有值,另一个表是子女表(人员编号,姓名,性别,出生日期,身份证号,母亲编号),其中子女表中的母亲标号就是全员信息表中的人员编号,理论上说子女表中的对应妇女编号的条目数应该是和子女数是一致的,但是现在有部分数据不一致。求帮助用sql语句查询出这些信息,输出信息的列为:人员编号,姓名,性别,身份证号,子女数,子女表中对应的条目数。rn谢谢!rn
求大神帮助!NoclassDefFoundError
将其他人写的项目导入自己的工作空间中。rn引用第三方包时,项目已经不报错了,但是一运行就报下面这个错误rn10-29 03:24:30.070: E/AndroidRuntime(808): java.lang.NoClassDefFoundError: android.support.v4.view.ViewConfigurationCompatrn这个类在我那个包里面是存在的。怎么都找不到。rn网上说过的方法我几乎都试过了,没用,还是这样。rnhttp://blog.csdn.net/huangrangg12/article/details/8131325rnhttp://ydpzg.blog.163.com/blog/static/17152629420127111178154/rn还有一些博客给出的解决方法就不贴出来了,总之都尝试过。不行~~~rn有木有大大碰到过这种情况啊~~rn搞了两天了。昨天下午本来弄好了,运行起来了。结果我不小心删除了工程,重新导又不行了。rn
求大神帮助!!!
package readmission.file;rn rn rnimport javax.servlet.http.*;rnimport javax.servlet.jsp.*;rnimport java.sql.*;rnrnimport javax.servlet.*;rnrnimport validata.ValidataNumber;rnrnimport java.util.* ;rnimport java.io.* ;rnimport include.nseer_db.*;rnimport include.nseer_cookie.*;rnimport include.operateDB.CdefineUpdate;rnrnpublic class outincount_ok extends HttpServletrnrnpublic synchronized void service(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletExceptionrnHttpSession dbSession=request.getSession();rnJspFactory _jspxFactory=JspFactory.getDefaultFactory();rnPageContext pageContext = _jspxFactory.getPageContext(this,request,response,"",true,8192,true);rnServletContext dbApplication=dbSession.getServletContext();rnServletContext application;rnHttpSession session=request.getSession();rnnseer_db_backup1 readmission_db=new nseer_db_backup1(dbApplication);rnnseer_db_backup1 finance_db=new nseer_db_backup1(dbApplication);rnValidataNumber validata=new ValidataNumber();rncounter count=new counter(dbApplication);rnString sql3="select * from readmission_patient";rnResultSet rs=readmission_db.executeQuery(sql3);rnString start_time=request.getParameter("start_time");rnString end_time=request.getParameter("end_time");rnString[] medicalnum=new String[100];rnint lcount=0;rntryrn if(readmission_db.conn((String)dbSession.getAttribute("unit_db_name")))rn rn int yes1=end_time.compareTo(start_time);rn if(yes1>0)rn rn rs.next();rn String register_in_time=rs.getString("register_in_time");rn System.out.println("register_in_time");rn int yes2=register_in_time.compareTo(start_time);rn if(yes2>=0)rn rn int yes3=register_in_time.compareTo(end_time);rn while(yes3<=0)rn rn medicalnum[lcount]=rs.getString("mediacl_num");rn lcount++;rn System.out.println("mediacl_num"+lcount);rn rs.next();rn rs.getString("register_in_time");rn yes3=register_in_time.compareTo(end_time);rn rn //String sql = "insert into readmission_patient(medical_num,hospital_num,name,sex,age,tel,card,address,state,anamnesis,remarks1,sections,bunk_num,remarks2,register,register_in_time,register_out_time) values ('"rn // +medical_num+"','"+hospital_num+"','"+name+"','"+sex+"','"+age+"','"+tel+"','"+card+"','"+address+"','"+state+"','"+anamnesis+"','"+remarks1+"','"+sections+"','"+bunk_num+"','"+remarks2+"','"+register+"','"+register_in_time+"','"+register_out_time+"','"+"')";rn response.sendRedirect("readmission/file/outincount_ok.jsp");rn rn rn elsern response.sendRedirect("readmission/file/outincount_not_ok.jsp"); rn rn elsern response.sendRedirect("readmission/file/outincount_not_ok.jsp");rn readmission_db.close();rn catch (Exception ex)rn ex.printStackTrace();rn rn rn rn运行到ResultSet rs=readmission_db.executeQuery(sql3);报错就不往下执行了!rn报错为:at include.nseer_db.nseer_db_backup1.executeQuery(nseer_db_backup1.java:100)rn at readmission.file.outincount_ok.service(outincount_ok.java:45)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 include.anti_repeat_submit.SubmitFilter.doFilter(SubmitFilter.java:85)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:230)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:261)rn at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)rn
类型转换 求大神帮助
Arraylist arr= new Arraylist();rnuser.setH_name(rs.getString("h_name"));rnuser.setH_age(rs.getString("h_age"));rnuser.setH_id(rs.getString("h_id"));rnuser.setH_phone(rs.getString("h_phone"));rnarr.add(user) rnrn数据库里面的 h_age 之类的都是 number类型的 rnrnuser里面 h_age定义的 是int类型 rnrnrn请问怎么将这里的int 类型的 H_age 转化成string类型呢??rn我想要的是 将 arraylist 里面全部存放 string类型rnrn新手发帖 求大声帮忙
相关热词 c# 标准差 计算 c#siki第五季 c#入门推荐书 c# 解码海康数据流 c# xml的遍历循环 c# 取 查看源码没有的 c#解决高并发 委托 c#日期转化为字符串 c# 显示问号 c# 字典对象池