关于安卓button的findviewbyid导致程序报错,和adapter的使用错误

package com.example.mp3test;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import android.app.Activity;
import android.database.Cursor;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.provider.MediaStore;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.SeekBar;
import android.widget.SimpleAdapter;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
import android.widget.TabWidget;

public class MainActivity extends Activity {
private TabHost tabHost;
private TabSpec specSongs;
private TabSpec specArtists;
private TabSpec specAlbums;
private TabSpec specPlaylist;

private MediaPlayer player;
private SeekBar audioSeekbar;

private Button playBtn;
private Button pauseBtn;
private Button nextBtn;
private Button preBtn;
private Button stopBtn;

private ListView songsList;
private ListView artistsList;
private ListView albumsList;
private ListView playList;

private List<Map<String,Object>> dataList;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    tabHost = (TabHost) findViewById(android.R.id.tabhost);
    tabHost.setup();
    audioSeekbar = (SeekBar) findViewById(R.id.seekBar1);

// playBtn = (Button) findViewById(R.id.imagebstart);
// nextBtn = (Button) findViewById(R.id.imagebnext);
// preBtn = (Button) findViewById(R.id.imagebpre);
// stopBtn = (Button) findViewById(R.id.imagebstop);
songsList = (ListView) findViewById(R.id.listSongs);
artistsList = (ListView) findViewById(R.id.listArtists);
albumsList = (ListView) findViewById(R.id.listAlbums);
playList = (ListView) findViewById(R.id.listPlaylist);
dataList = new ArrayList>();
//init();
//set_tab_style();
add_tabs();
//set_Adapter();
}

private void init(){
    tabHost = (TabHost) findViewById(android.R.id.tabhost);
    audioSeekbar = (SeekBar) findViewById(R.id.seekBar1);
    playBtn = (Button) findViewById(R.id.imagebstart);
    nextBtn = (Button) findViewById(R.id.imagebnext);
    preBtn = (Button) findViewById(R.id.imagebpre);
    stopBtn = (Button) findViewById(R.id.imagebstop);
    songsList = (ListView) findViewById(R.id.listSongs);
    artistsList = (ListView) findViewById(R.id.listArtists);
    albumsList = (ListView) findViewById(R.id.listAlbums);
    playList = (ListView) findViewById(R.id.listPlaylist);
    dataList = new ArrayList<Map<String,Object>>();
}

private void set_Adapter(){
    setListAdpter(songsList, getMp3Infos("songs"));
    setListAdpter(artistsList, getMp3Infos("artists"));
    setListAdpter(albumsList, getMp3Infos("albums"));
    setListAdpter(playList, getMp3Infos("playlist"));
}

private void set_tab_style(){
    LinearLayout layout = (LinearLayout)tabHost.getChildAt(0);
    TabWidget tw = (TabWidget)layout.getChildAt(0);
}

private void add_tabs(){
    specSongs = tabHost.newTabSpec("Tab 1");
    specSongs.setContent(R.id.tabSongs);
    specSongs.setIndicator("Songs");
    tabHost.addTab(specSongs);

    specArtists = tabHost.newTabSpec("Tab 2");
    specArtists.setContent(R.id.tabArtists);
    specArtists.setIndicator("Artists");
    tabHost.addTab(specArtists);

    specAlbums = tabHost.newTabSpec("Tab 3");
    specAlbums.setContent(R.id.tabAlbums);
    specAlbums.setIndicator("Albums");
    tabHost.addTab(specAlbums);

    specPlaylist = tabHost.newTabSpec("Tab 4");
    specPlaylist.setContent(R.id.tabPlaylist);
    specPlaylist.setIndicator("Playlist");
    tabHost.addTab(specPlaylist);
}

public List<Mp3Info> getMp3Infos(String c){
    Cursor cursor = null;
    if(c.equals("songs")){
        cursor = getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
                null, null, null, MediaStore.Audio.Media.DEFAULT_SORT_ORDER);
    }
    else if(c.equals("artists")){
        cursor = getContentResolver().query(MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI,
                null, null, null, MediaStore.Audio.Artists.DEFAULT_SORT_ORDER);
    }
    else if(c.equals("albums")){
        cursor = getContentResolver().query(MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI,
                null, null, null, MediaStore.Audio.Albums.DEFAULT_SORT_ORDER);
    }
    else if(c.equals("playlist")){
        cursor = getContentResolver().query(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
                null, null, null, MediaStore.Audio.Playlists.DEFAULT_SORT_ORDER);
    }
    List<Mp3Info> mp3Infos = new ArrayList<Mp3Info>();
    for(int i = 0; i < cursor.getCount(); ++i){
        Mp3Info mp3info = new Mp3Info();
        cursor.moveToNext();
        String title = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.TITLE));
        String album = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.ALBUM));
        String artist = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.ARTIST));
        long duration = cursor.getLong(cursor.getColumnIndex(MediaStore.Audio.Media.DURATION));
        int isMusic = cursor.getInt(cursor.getColumnIndex(MediaStore.Audio.Media.IS_MUSIC));
        if(isMusic != 0){
            mp3info.title = title;
            mp3info.album = album;
            mp3info.artist = artist;
            mp3info.duration = duration;
            mp3Infos.add(mp3info);
        }
    }
    return mp3Infos;
}

public void setListAdpter(ListView mMusiclist, List<Mp3Info> mp3Infos) {
    for (Iterator iterator = mp3Infos.iterator(); iterator.hasNext();) {
        Mp3Info mp3Info = (Mp3Info) iterator.next();
        HashMap<String, Object> map = new HashMap<String, Object>();
        map.put("title", mp3Info.getTitle());
        map.put("Artist", mp3Info.getArtist());
        map.put("pic", R.drawable.music);
        dataList.add(map);
    }
    SimpleAdapter mAdapter = new SimpleAdapter(this, dataList,
            R.layout.item, new String[] { "title", "Artist", "pic" },
            new int[] {R.id.itemsongs, R.id.itemArtists, R.id.itempic });
    mMusiclist.setAdapter(mAdapter);      
}  

public class Mp3Info{
    private String title;
    private String album;
    private String artist;
    private long duration;

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getAlbum() {
        return album;
    }

    public void setAlbum(String album) {
        this.album = album;
    }

    public String getArtist() {
        return artist;
    }

    public void setArtist(String artist) {
        this.artist = artist;
    }

    public long getDuration() {
        return duration;
    }

    public void setDuration(long duration) {
        this.duration = duration;
    }
}

}


以上代码,谢谢

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
Android Studio 中Button控件的问题

目前在参考《第一行代码Android 第二版》 看到书中 第2.2.4节 在活动中使用Toast 其中我在写码Button的时候我的AS会报错 ![图片说明](https://img-ask.csdn.net/upload/201910/13/1570978836_981403.png) 附MainActivity.kt的代码 ``` package com.example.myapplication import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.view.View import android.widget.Button import android.widget.Toast class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState); setContentView(R.layout.first_layout); Button button_1 = (Button) findViewById(R.id.button_1); button1 .setOnClickListener(new View.onClickListener) { @Override public void onClick(View v){ Toast.makeText(MainActivity.this,"You Clcke Button 1",Toast.LENGTH_SHORT).show(); } }; } } ``` 谢谢@王能指出代码没贴出来 此上为问题代码![图片说明](https://img-ask.csdn.net/upload/201910/15/1571136452_474511.png)

Button onClick事件不能运行

我创建一个viewPager,在每一个页面上有三个布局。在第二个页面上我想处理按钮事件,当点击按钮时背景颜色会变。但是现在我的代码不能运行。去掉button代码,viewPager就可以正常运行。 这是我的代码: public class ViewPagerProjectActivity extends Activity implements OnClickListener{ Button btn; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ViewPagerAdapter adapter = new ViewPagerAdapter( this ); ViewPager pager = (ViewPager)findViewById( R.id.viewpager ); pager.setAdapter( adapter ); pager.setCurrentItem(0); } public void OnClick(View v) { if(v.equals(btn)) { LinearLayout l = (LinearLayout) findViewById(R.id.deneme2); l.setBackgroundDrawable(getResources().getDrawable(R.drawable.background)); } } } 错误: E/AndroidRuntime(273): FATAL EXCEPTION: main E/AndroidRuntime(273): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.yahya.ViewPagerProject/com.yahya.ViewPagerProject.ViewPagerProjectActivity}: java.lang.ClassCastException: com.yahya.ViewPagerProject.ViewPagerProjectActivity E/AndroidRuntime(273): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663) E/AndroidRuntime(273): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) E/AndroidRuntime(273): at android.app.ActivityThread.access$2300(ActivityThread.java:125)

android adapter空指针异常

``` public class MainActivity extends AppCompatActivity { DatabaseHelper databaseHelper; private static Toolbar mToolbar; private static TextView mMaintitle,mMaincontent,mMaintime; public static EditText dlx_Input1,dlx_Input2; public static String datetime; public static View mLine; MyAdapter myAdapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); findName(); setSupportActionBar(mToolbar); databaseHelper = new DatabaseHelper(this, databaseHelper.DATABASE_NAME, null, databaseHelper.DATABASE_VERSION); //myAdapter.getData2(); myAdapter = new MyAdapter(this); myAdapter.lv = (ListView)findViewById(R.id.lv); myAdapter.data = myAdapter.getData(); MyAdapter adapter = new MyAdapter(this); myAdapter.lv.setAdapter(adapter); } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_add: showDialog_Layout(MainActivity.this); } return super.onOptionsItemSelected(item); } public void findName() { mToolbar = (Toolbar) findViewById(R.id.toolbar); mMaintitle = (TextView)findViewById(R.id.dlx_maintitle); mMaincontent = (TextView)findViewById(R.id.dlx_maincontent); mMaintime = (TextView)findViewById(R.id.dlx_maintime); mLine = (View)findViewById(R.id.dlx_line); } private void showDialog_Layout(Context context) { dlx_Input1 = (EditText)findViewById(R.id.dlx_Input1); dlx_Input2 = (EditText)findViewById(R.id.dlx_Input2); final AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setCancelable(false); builder.setTitle(R.string.dlx_add); builder.setPositiveButton("CANCEL", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { setTitle(""); } }); builder.setNegativeButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { SQLiteDatabase db = databaseHelper.getWritableDatabase(); ContentValues values = new ContentValues(); SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); datetime = s.format(new java.util.Date()); values.put("title", String.valueOf(dlx_Input1.getText())); values.put("content", String.valueOf(dlx_Input2.getText())); values.put("time", datetime); db.insert(databaseHelper.TABLE_NAME, null, values); myAdapter.getData(); } }); builder.show(); } @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.menu, menu); menu.findItem(R.id.action_add).setChecked(true); return super.onCreateOptionsMenu(menu); } } public class MyAdapter extends BaseAdapter { public static ListView lv; public static List<Map<String, Object>> data; public LayoutInflater mInflater = null; MainActivity mainActivity; DatabaseHelper databaseHelper; public MyAdapter(Context context) { this.mInflater = LayoutInflater.from(context); } public List<Map<String, Object>> getData() { List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(); Map<String, Object> map; for(int i=0;i<10;i++) { map = new HashMap<String, Object>(); map.put("title",String.valueOf(mainActivity.dlx_Input1.getText())); map.put("content", String.valueOf(mainActivity.dlx_Input2.getText())); map.put("time",mainActivity.datetime); list.add(map); } return list; } static class ViewHolder { public TextView title; public TextView content; public TextView time; public View line; } public int getCount() { //How many items are in the data set represented by this Adapter. //在此适配器中所代表的数据集中的条目数 return data.size(); } public Object getItem(int position) { // Get the data item associated with the specified position in the data set. //获取数据集中与指定索引对应的数据项 return position; } public long getItemId(int position) { //Get the row id associated with the specified position in the list. //获取在列表中与指定索引对应的行id return position; } //Get a View that displays the data at the specified position in the data set. //获取一个在数据集中指定索引的视图来显示数据 public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder = null; //如果缓存convertView为空,则需要创建View if(convertView == null) { holder = new ViewHolder(); //根据自定义的Item布局加载布局 convertView = mInflater.inflate(R.layout.commentlayout, null); holder.title = (TextView)convertView.findViewById(R.id.dlx_maintitle); holder.content = (TextView)convertView.findViewById(R.id.dlx_maincontent); holder.time = (TextView)convertView.findViewById(R.id.dlx_maintime); holder.line = (View)convertView.findViewById(R.id.dlx_line); //将设置好的布局保存到缓存中,并将其设置在Tag里,以便后面方便取出Tag convertView.setTag(holder); }else { holder = (ViewHolder)convertView.getTag(); } holder.title.setText((String)data.get(position).get("title")); holder.content.setText((String)data.get(position).get("content")); holder.time.setText((String)data.get(position).get("time")); holder.line.setBackgroundColor(mainActivity.getResources().getColor(R.color.colorPrimaryDark)); return convertView; } ``` 在map.put("title",String.valueOf(mainActivity.dlx_Input1.getText()));和myAdapter.data = myAdapter.getData();报空指针异常 Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.text.Editable android.widget.EditText.getText()' on a null object reference,求大神指点!!!

android程序,eclipse没报错,但是运行会意外停止

我是一个初学android者,很多简单的问题大家都看着很简单而我不知道为什么,所以希望耐心的大神帮忙回答一下!我很着急~~~ 这是OtherActivity.java public class OtherActivity extends MainActivity { private Button btn1; private TextView myTextView = null; private ListView listView; private SimpleAdapter adapter; private DBUtil dbUtil; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.other); Intent intent = getIntent(); String value = intent.getStringExtra("testIntent"); myTextView = (TextView)findViewById(R.id.myTextView); myTextView.setText(value); btn1 = (Button) findViewById(R.id.btn_all); listView = (ListView) findViewById(R.id.listView); dbUtil = new DBUtil(); btn1.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { hideButton(true); setListView(); } }); } private void setListView() { listView.setVisibility(View.VISIBLE); List<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>(); String str = "select * from v_jy where enginen like '%" + "enginen" + "%'"; list = dbUtil.selectAllfromv_jy(str); adapter = new SimpleAdapter( OtherActivity.this, list, R.layout.adapter_item, new String[] {"sysid", "reportn", "enginen" ,"exreport","exsdate","uaddress","maddress","factoryn","exaddress","no" }, new int[] { R.id.txt_Cno,R.id.txt_Cna,R.id.txt_Cnb,R.id.txt_Cnc,R.id.txt_Cnd,R.id.txt_Cne,R.id.txt_Cnf,R.id.txt_Cng,R.id.txt_Cnh,R.id.txt_Cni}); listView.setAdapter(adapter); } DBUtil.java如下: public class DBUtil { //private static final String Soaptest = null; private ArrayList<String> arrayList = new ArrayList<String>(); private ArrayList<String> brrayList = new ArrayList<String>(); private ArrayList<String> crrayList = new ArrayList<String>(); private HttpConnSoap Soap = new HttpConnSoap(); public static Connection getConnection() { Connection con = null; try { //Class.forName("org.gjt.mm.mysql.Driver"); //con=DriverManager.getConnection("jdbc:mysql://192.168.0.106:3306/test?useUnicode=true&characterEncoding=UTF-8","root","initial"); } catch (Exception e) { //e.printStackTrace(); } return con; } public List<HashMap<String, String>> selectAllfromv_jy(String enginen) { List<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>(); arrayList.clear(); brrayList.clear(); crrayList.clear(); arrayList.add("enginen"); brrayList.add(enginen); crrayList = Soap.GetWebServer("selectAllfromv_jy", arrayList, brrayList); Soap.GetWebServer("selectAllfromv_jy", arrayList, brrayList); HashMap<String, String> tempHash = new HashMap<String, String>(); tempHash.put("sysid", "sysid"); tempHash.put("reportn", "reportn"); tempHash.put("enginen", "enginen"); tempHash.put("exreport", "exreport"); tempHash.put("exsdate", "exsdate"); tempHash.put("uaddress", "uaddress"); tempHash.put("maddress", "maddress"); tempHash.put("factoryn", "factoryn"); tempHash.put("exaddress", "exaddress"); tempHash.put("no", "no"); list.add(tempHash); //DBUtil dbUtil = null; //list = dbUtil.getAllfromv_jy(); for (int j = 0; j < crrayList.size(); j += 10) { HashMap<String, String> hashMap = new HashMap<String, String>(); hashMap.put("sysid", crrayList.get(j)); hashMap.put("reportn", crrayList.get(j + 1)); hashMap.put("enginen", crrayList.get(j + 2)); hashMap.put("exreport", crrayList.get(j + 3)); hashMap.put("exsdate ", crrayList.get(j + 4)); hashMap.put("uaddress", crrayList.get(j + 5)); hashMap.put("maddress", crrayList.get(j + 6)); hashMap.put("factoryn", crrayList.get(j + 7)); hashMap.put("exaddress", crrayList.get(j + 8)); hashMap.put("no", crrayList.get(j + 9)); list.add(hashMap); } return list; } logcat代码: 05-13 16:07:18.040: I/System.out(14028): /soap:Body 05-13 16:07:18.040: D/AndroidRuntime(14028): Shutting down VM 05-13 16:07:18.040: W/dalvikvm(14028): threadid=1: thread exiting with uncaught exception (group=0x4001e578) 05-13 16:07:18.050: E/AndroidRuntime(14028): FATAL EXCEPTION: main 05-13 16:07:18.050: E/AndroidRuntime(14028): java.lang.NullPointerException 05-13 16:07:18.050: E/AndroidRuntime(14028): at com.example.crane5.DBUtil.selectAllfromv_jy(DBUtil.java:66) 05-13 16:07:18.050: E/AndroidRuntime(14028): at com.example.crane5.OtherActivity.setListView(OtherActivity.java:61) 05-13 16:07:18.050: E/AndroidRuntime(14028): at com.example.crane5.OtherActivity.access$1(OtherActivity.java:54) 05-13 16:07:18.050: E/AndroidRuntime(14028): at com.example.crane5.OtherActivity$1.onClick(OtherActivity.java:48) 05-13 16:07:18.050: E/AndroidRuntime(14028): at android.view.View.performClick(View.java:2538) 05-13 16:07:18.050: E/AndroidRuntime(14028): at android.view.View$PerformClick.run(View.java:9152) 05-13 16:07:18.050: E/AndroidRuntime(14028): at android.os.Handler.handleCallback(Handler.java:587) 05-13 16:07:18.050: E/AndroidRuntime(14028): at android.os.Handler.dispatchMessage(Handler.java:92) 05-13 16:07:18.050: E/AndroidRuntime(14028): at android.os.Looper.loop(Looper.java:130) 05-13 16:07:18.050: E/AndroidRuntime(14028): at android.app.ActivityThread.main(ActivityThread.java:3691) 05-13 16:07:18.050: E/AndroidRuntime(14028): at java.lang.reflect.Method.invokeNative(Native Method) 05-13 16:07:18.050: E/AndroidRuntime(14028): at java.lang.reflect.Method.invoke(Method.java:507) 05-13 16:07:18.050: E/AndroidRuntime(14028): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907) 05-13 16:07:18.050: E/AndroidRuntime(14028): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665) 05-13 16:07:18.050: E/AndroidRuntime(14028): at dalvik.system.NativeStart.main(Native Method)

android 当在主线程里开启一个新线程 程序就崩溃

我要实现的功能是检索SDcard里的所有txt文件 我尝试过很多办法 1 不用线程 直接在主线程里检索文件 由于有循环且检索时间会超过5秒 导致黑屏然后提示未响应 2 我建立一个线程让线程去检索文件当检索完毕后把检索到的文件传递给主类 主类再把检索到的文件显示在list上 但是当线程一启动程序就崩溃了 3 最后我在主类里添加handler 当子线程检索完毕就sendmessage给主类 然后主类把子线程检索到的文件显示在list上但程序还是崩溃 我没在子线程里操作UI 好像只要子线程里有循环程序就会崩溃 下面我把代码贴出来希望大家能帮帮我解决下这个问题 主类的主要代码 enter code here int jishuqi = 0; ProgressDialog progress; jiansuothread thread; Intent intent; int[] leixing_xuanzhe; FileReader file; File fuwenjian; File fuwenjianxia[]; String[] leixing = new String[] {"doc","pdf","xls","txt","jpg","ppt"}; int i = 0; ArrayList<File[]>root = new ArrayList<File[]>(); String xuanxiang [] = new String [] {"向上","编辑","添加","删除"}; int ico [] = new int[] {R.drawable.xinjian,R.drawable.xinjian,R.drawable.xinjian,R.drawable.xinjian}; ListView list; Button xiangshang; Button bianji; Button tianjia; Button shanchu; View v; static ArrayList<File[]>jiansuoroot = new ArrayList<File[]>(); static List<File>jiansuowenjian = new ArrayList<File>(); static File fi; static ArrayList<File>wenjianjia = new ArrayList<File>(); static ArrayList<File>ziwenjian = new ArrayList<File>(); static ArrayList<File[]>ziwenjian1 = new ArrayList<File[]>(); static ArrayList<File[]>rootwenjianjia = new ArrayList<File[]>(); //jiansuowen js = new jiansuowen(); //zixiancheng xiancheng = null; Handler hanlder; Handler handler = null; Handler childhandler = null; boolean jiansuowanbi = false; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_text); xiancheng = new zixiancheng(); xiancheng.start(); v = (View)findViewById(R.id.view1); intent = this.getIntent(); leixing_xuanzhe = intent.getIntArrayExtra("leixing_xuanzhe"); list = (ListView)findViewById(R.id.fileslist); parse(leixing_xuanzhe); list.setOnItemClickListener(new mylistitemclick()); xiangshang = (Button)findViewById(R.id.wj_xiangshang); bianji = (Button)findViewById(R.id.wj_bianji); tianjia = (Button)findViewById(R.id.wj_tianjia); shanchu = (Button)findViewById(R.id.wj_shanchu); xiangshang.setOnClickListener(new myClick()); bianji.setOnClickListener(new myClick()); tianjia.setOnClickListener(new myClick()); shanchu.setOnClickListener(new myClick()); //thread = new jiansuothread(this); handler = new Handler() { @Override public void handleMessage(Message msg) { // TODO Auto-generated method stub if(msg.what == 111) { progress.cancel(); List<Map<String,Object>>listitems = new ArrayList<Map<String,Object>>(); for(int i= 0;i<jiansuowenjian.size();i++) { Map<String,Object>item = new HashMap<String,Object>(); item.put("icon",R.drawable.file ); item.put("name", jiansuowenjian.get(i).getName()); listitems.add(item); } SimpleAdapter adpter = new SimpleAdapter(TexlisttActivity.this,listitems , R.layout.list, new String[] {"icon","name"}, new int[] {R.id.icon,R.id.listitem}); list.setAdapter(adpter); } } }; }` 子线程的代码 enter code here` class zixiancheng extends Thread { Message msg = null; public void run() { Looper.prepare(); childhandler = new Handler() { @Override public void handleMessage(Message msg) { // TODO Auto-generated method stub if(msg.what == 222) { try { for(int i =0; i<wenjianjia.size();i++) { jinasuo1(wenjianjia.get(i)); } jiansuowanbi = true; msg = handler.obtainMessage(); msg.what = 111; handler.sendMessage(msg); } catch (Exception e) { // TODO: handle exception } } } }; Looper.loop(); } }

【Android studio】 【onClick NullPointerException】 java.lang.NullPointerException: Attempt to invoke interface method ··········.Adapter.goods_Adapter.onClick(goods_Adapter.java:44)

【Android studio】 【onClick NullPointerException】 报错:java.lang.NullPointerException: Attempt to invoke interface method ··········.Adapter.goods_Adapter.onClick(goods_Adapter.java:44) 空指针,在listview里的item设置了按钮监听事件 代码: ``` package com.example.nero.thecashregistersystem.Adapter; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ImageButton; import android.widget.TextView; import com.example.nero.thecashregistersystem.R; import com.example.nero.thecashregistersystem.bean.goodsInfo; import java.util.List; public class goods_Adapter extends ArrayAdapter<goodsInfo> implements View.OnClickListener { private int mResource; List<goodsInfo> goodsinfo ; private Context mContext; private LayoutInflater mInflater; // private MyClickListener mListener;//所有listview的item共用同一个 private BtnOnclick btnOnclick; public BtnOnclick getBtnOnclick() { return btnOnclick; } public void setBtnOnclick(BtnOnclick bottomBtnOnclick) { this.btnOnclick = btnOnclick; } public interface BtnOnclick{ public void click(View view,int index); } @Override public void onClick(View view) { btnOnclick.click(view,(int)view.getTag());//**这行代码报错** } //原: public goods_Adapter(Context context, int resource, List<goodsInfo> objects) { super(context, resource, objects); // mResource = R.layout.item; mResource = resource; } @Override public View getView(final int position, View convertView, ViewGroup parent) { goodsInfo goodsinfo = getItem(position); View view; ViewHolder viewHolder; if (convertView == null){ view = LayoutInflater.from(getContext()).inflate(mResource,null); viewHolder = new ViewHolder(); viewHolder.name = (TextView) view.findViewById(R.id.listview_name); viewHolder.goods_number = (TextView) view.findViewById(R.id.listview_goodsnumber); viewHolder.in_price = (TextView) view.findViewById(R.id.listview_inprice); viewHolder.out_price = (TextView) view.findViewById(R.id.listview_outprice); viewHolder.update_time = (TextView) view.findViewById(R.id.listview_updatetime); viewHolder.btn_add_jiesuan = (ImageButton) view.findViewById(R.id.btn_add_jiesuan); view.setTag(viewHolder); } else{ view = convertView; viewHolder = (ViewHolder) view.getTag(); } viewHolder.name.setText(goodsinfo.getName()); viewHolder.goods_number.setText(goodsinfo.getgoods_number()); viewHolder.in_price.setText(goodsinfo.getin_price()+""); viewHolder.out_price.setText(goodsinfo.getout_price()+""); viewHolder.update_time.setText(goodsinfo.getupdate_time()); //设置按钮监听 viewHolder.btn_add_jiesuan.setOnClickListener(this); viewHolder.btn_add_jiesuan.setTag(position); return view; } class ViewHolder{ TextView name; TextView goods_number; TextView in_price; TextView out_price; TextView update_time; ImageButton btn_add_jiesuan; // int position; } } ``` 在fragment里的相关代码是 ``` private void InitListview(final List<goodsInfo> goodsArray){ adapter = new goods_Adapter(getActivity(),R.layout.item,goodsArray); lv.setAdapter(adapter); adapter.setBtnOnclick(new goods_Adapter.BtnOnclick() { @Override public void click(View view, int index) { switch (view.getId()){ case R.id.btn_add_jiesuan: Toast.makeText( getActivity(), "listview的内部的按钮被点击了!,位置是:" + (Integer) view.getTag() + ",内容是-->" + goodsArray.get((Integer) view.getTag()).name, Toast.LENGTH_SHORT).show(); break; } } }); } ``` 而且报错那行还debug不了,不知道为什么,其他地方就可以debug。 view = LayoutInflater.from(getContext()).inflate(mResource,null);确定是item的id,debug看过了 希望大佬告诉我请问问题出在哪里??谢谢!!!

Android提示错误:on a null object reference

我是在button的onclick里写的用的swith,一按按钮就崩溃,后来捕捉错误为 Attempt to invoke virtual method 'android.text.Editable android.widget.EditText.getText()' on a null object reference 但是我et应该有值啊,不理解 case R.id.next: EditText et = (EditText) v.findViewById(R.id.number); try { System.out.println(et.getText().toString());//这句话报错 } catch (Exception ex) { System.out.println("Error :" + ex.getMessage()); } break;

什么错误会使应用程序崩溃呢?

当我点击应用程序的logo,闪屏后,就会从intent中调用的第一个类。但是当tab加载后, onPreExecute() 一旦执行,应用程序就奔溃了。 public class HomeActivity extends Activity{ private static final String dialog = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.user_main_tab_home); new HomeDownloadPage().execute(); } public class HomeDownloadPage extends AsyncTask<String,Void,String>{ private final ProgressDialog dialog = new ProgressDialog(HomeActivity.this); protected void onPreExecute() { this.dialog.setMessage("Have Paitence! "); this.dialog.show(); } @Override protected String doInBackground(String... params) { User user = null; try { user = new User("4eeb"); user.getList(); /* * Custom adapter * */ ArrayList<User> users = new ArrayList<User>(); for(User u : user.following){ users.add(u); } ListView lv = (ListView) findViewById(R.id.user_list); final UserFollowingListAdapter csl = new UserFollowingListAdapter(HomeActivity.this,R.layout.user_list,users,this); OnItemClickListener listener = new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position,long id) { Object o = csl.getItem(position); setTitle(parent.getItemAtPosition(position).toString()); } }; lv.setAdapter(csl); lv.setOnItemClickListener(listener); /* * Onclick listener * */ lv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view,int position, long id) { Intent i = new Intent("com.list.SEARCH"); Toast.makeText(HomeActivity.this, "rowitem clicked", Toast.LENGTH_LONG).show(); // TODO Auto-generated method stub } }); } catch (Exception e) { showError(); } return null; } protected void onPostExecute(String result) { // execution of result of Long time consuming operation } } public void showError(){ new AlertDialog.Builder(HomeActivity.this) .setTitle(" Oops , Server down :( ") .setPositiveButton("Ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { // TODO Auto-generated method stub } // }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Do nothing. } }).show(); } } 在 doInBackground() 函数处得到错误。 确切的错误: 01-27 19:03:01.264: E/AndroidRuntime(1138): Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare() 问题出在哪呢?

使用recyclerView更新数据时程序崩溃

我在编写“添加好友”模块时,根据用户输入的用户名,从服务器获取到了相应信息,但将该数据载入recyclerView更新时程序却崩溃了。接下来是我的代码,以及错误日志。求助大家,小白一只,挣扎了一星期也没找到问题所在。 此为主活动部分:思路是获取输入框的用户名,进入Bmob数据库查询。我调试的时候看到用户是成功查询到的。 public class FriendAdd extends AppCompatActivity { private Button searchUser; private EditText newFriendName; private List<Friend> newFriendList=new ArrayList<>(); private RecyclerView recyclerView; private StrangerAdapter adapter; private LinearLayoutManager layoutManager; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_add_friend); searchUser = (Button) findViewById(R.id.addFriend_button_fingNewFriend); newFriendName = (EditText) findViewById(R.id.addFriend_editText_inputFriendName); recyclerView=(RecyclerView)findViewById(R.id.addFriend_recyclerView); adapter =new StrangerAdapter(); layoutManager = new LinearLayoutManager(this); recyclerView.setLayoutManager(layoutManager); recyclerView.setAdapter(adapter); searchUser.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String strangerName=newFriendName.getText().toString(); if(strangerName.isEmpty()){ createDialog("用户名为空","请输入您所查找用户的用户名"); }else{ BmobQuery<User> query = new BmobQuery<User>(); query.addWhereEqualTo("trueName", strangerName); query.findObjects(new FindListener<User>() { @Override public void done(List<User> object, BmobException e) { if(e==null){ for (User gameScore : object) { //获得信息 Friend newFriend=new Friend(gameScore.gettureName(),gameScore.getdepartment()); newFriendList.add(newFriend); } adapter.setDatas(newFriendList); adapter.notifyDataSetChanged(); }else{ createDialog("查询用户失败",e.getMessage()+e.getErrorCode()); } } }); } } }); } private void createDialog(String title, String msg) { AlertDialog.Builder b=new AlertDialog.Builder(this); b.setMessage(msg); b.setTitle(title); b.setNegativeButton("重试", new DialogInterface.OnClickListener(){ public void onClick(DialogInterface dialog,int which){ dialog.dismiss(); } }); b.create().show(); } } 以下为recyclerView的数据适配器代码: public class StrangerAdapter extends RecyclerView.Adapter<StrangerAdapter.ViewHolder> { private List<Friend> stranger=new ArrayList<>(); static class ViewHolder extends RecyclerView.ViewHolder{ ImageView friendImage; TextView friendName; TextView friendDepartment; public ViewHolder(View view){ super(view); friendImage=(ImageView)view.findViewById(R.id.friendSearch_image_head); friendName=(TextView)view.findViewById(R.id.friendSearch_textView_userName); friendDepartment=(TextView)view.findViewById(R.id.friendSearch_textView_department); } } public StrangerAdapter() { }; public StrangerAdapter(List<Friend> friendList){ stranger=friendList; } public ViewHolder onCreateViewHolder(ViewGroup parent,int viewType){ View view=LayoutInflater.from(parent.getContext()).inflate(R.layout.friend_list_item,parent,false); ViewHolder holder=new ViewHolder(view); return holder; } public void onBindViewHolder(ViewHolder holder,int position){ Friend friend=stranger.get(position); holder.friendImage.setImageResource(friend.getImageId()); holder.friendName.setText(friend.getName()); holder.friendDepartment.setText(friend.getLocation()); } public int getItemCount(){ return stranger.size(); } public void setDatas(List<Friend> list) { stranger.clear(); if (null != list) { stranger.addAll(list); } } } 以下是崩溃后输出的错误日志 04-23 15:28:24.143 16212-16212/com.example.schoolpet E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.schoolpet, PID: 16212 java.lang.ExceptionInInitializerError at java.lang.Class.newInstance(Native Method) at android.app.Instrumentation.newActivity(Instrumentation.java:1070) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2349) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2511) at android.app.ActivityThread.access$900(ActivityThread.java:165) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1375) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:150) at android.app.ActivityThread.main(ActivityThread.java:5621) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:684) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context cn.bmob.v3.BmobWrapper.getApplicationContext()' on a null object reference at cn.bmob.v3.Bmob.Code(Bmob.java:117) at cn.bmob.v3.Bmob.getApplicationContext(Bmob.java:129) at cn.bmob.v3.b.The.<init>(SPUtil.java:28) at cn.bmob.v3.BmobUser.getCurrentUser(BmobUser.java:871) at com.example.schoolpet.PetPage.<clinit>(PetPage.java:59) at java.lang.Class.newInstance(Native Method)  at android.app.Instrumentation.newActivity(Instrumentation.java:1070)  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2349)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2511)  at android.app.ActivityThread.access$900(ActivityThread.java:165)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1375)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:150)  at android.app.ActivityThread.main(ActivityThread.java:5621)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:684) 

安卓蓝牙,BluetoothAdapter.getRemoteDevice()报错

``` public class PathFragment extends Fragment { private Button scanBT; public static final int MY_PERMISSION_REQUEST_CONSTANT = 1; public static final int MESSAGE_STATE_CHANGE = 1; public static final int MESSAGE_READ = 2; public static final int MESSAGE_WRITE = 3; public static final int MESSAGE_DEVICE_NAME = 4; public static final int MESSAGE_TOAST = 5; // Key names received from the BluetoothChatService Handler public static final String DEVICE_NAME = "device_name"; public static final String TOAST = "toast"; // Intent请求码 private static final int REQUEST_CONNECT_DEVICE = 1; private static final int REQUEST_ENABLE_BT = 2; private static final int REQUEST_NEW_CARD = 3; private String mConnectedDeviceName = null; private BluetoothAdapter mBluetoothAdapter = null; private BluetoothService mBlueService = null; String recieveStr = "";//暂存当前发过来的字节 int n = 0; MyDatabaseHelper myDatabaseHelper; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View pathLayout = inflater.inflate(R.layout.path_layout, container, false); return pathLayout; } @Override public void onActivityCreated(Bundle savedInstanceState) {//当Activity中的onCreate方法执行完后调用。 super.onActivityCreated(savedInstanceState); //打开数据库 myDatabaseHelper = new MyDatabaseHelper(getActivity(),"csport.db",null,1); initViews(); scanBT.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent serverIntent = new Intent(getActivity(), DeviceListActivity.class); startActivityForResult(serverIntent,REQUEST_CONNECT_DEVICE); } }); } private void initViews() { scanBT = (Button)getActivity().findViewById(R.id.button_scan); } public void onDestroy() { super.onDestroy(); // Stop the Bluetooth chat services if (mBlueService != null) mBlueService.stop(); } @Override public synchronized void onResume() { super.onResume(); // Performing this check in onResume() covers the case in which BT was // not enabled during onStart(), so we were paused to enable it... // onResume() will be called when ACTION_REQUEST_ENABLE activity returns. if (mBlueService != null) { // Only if the state is STATE_NONE, do we know that we haven't started already if (mBlueService.getState() == BluetoothService.STATE_NONE) { // Start the Bluetooth chat services mBlueService.start(); } } } //处理线程返回信息 private final Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { switch (msg.what) { case MESSAGE_STATE_CHANGE://1 Toast.makeText(getActivity(), "change", Toast.LENGTH_LONG); switch (msg.arg1) { case BluetoothService.STATE_CONNECTED: //mTitle.setText(R.string.title_connected_to); //mTitle.append(mConnectedDeviceName); //mConversationArrayAdapter.clear(); break; case BluetoothService.STATE_CONNECTING: //mTitle.setText(R.string.title_connecting); break; case BluetoothService.STATE_LISTEN: case BluetoothService.STATE_NONE: //mTitle.setText(R.string.title_not_connected); break; } break; //发送了信息,显示在本地屏幕上(重写,显示结果即可) case MESSAGE_WRITE://2 Toast.makeText(getActivity(), "发送成功", Toast.LENGTH_LONG); break; //收到了信息,显示在本地屏幕上(重写,加入到通信录中) case MESSAGE_READ://3读取数据 byte[] readBuf = (byte[]) msg.obj; recieveStr = new String(readBuf, 0, msg.arg1); if (recieveStr.length() > 7) { break; } else { float res = 0; if (recieveStr != null && recieveStr.length() > 0) { res = Float.parseFloat(recieveStr); //arrayList.add(res); //n ++ ; //Log.e("Tag",String.valueOf(arrayList)); //Log.e("Tag",String.valueOf(n)); } if (n == 30) { //analyzer.deal(MainActivity.this,arrayList); //重置n和arrlist准备接收下一个5min的数据 n = 0; //arrayList.clear(); } } //tView.setText(recieveStr); //writeFile(recieveStr); break; case MESSAGE_DEVICE_NAME://4 // save the connected device's name mConnectedDeviceName = msg.getData().getString(DEVICE_NAME); Toast.makeText(getActivity(), "已成功连接到 " + mConnectedDeviceName, Toast.LENGTH_SHORT).show(); //requestSend();//初次连接成功后请求重发 break; case MESSAGE_TOAST://5 Toast.makeText(getActivity(), msg.getData().getString(TOAST), Toast.LENGTH_SHORT).show(); break; } } }; //处理其他Activity的返回结果 public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case REQUEST_CONNECT_DEVICE://1 //当点击了设备列表后返回所指向设备的MAC地址,根据此MAC进行主动连接 if (resultCode == Activity.RESULT_OK) { String address = data.getExtras().getString(DeviceListActivity.EXTRA_DEVICE_ADDRESS); BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address); mBlueService.connect(device); } break; case REQUEST_ENABLE_BT://2 //由确认打开蓝牙Activity返回,若打开成功初始化名片列表 if (resultCode == Activity.RESULT_OK) { // Bluetooth is now enabled, so set up a chat session setupCards(); } else { // User did not enable Bluetooth or an error occured Toast.makeText(getActivity(), R.string.bt_not_enabled_leaving, Toast.LENGTH_SHORT).show(); //finish(); } break; case REQUEST_NEW_CARD://3 //由添加新名片Activity返回,若添加了新card重新读取并显示 if (resultCode == Activity.RESULT_OK) { setupCards(); } break; } } private void setupCards() { //完成显示内容后,初始化蓝牙服务对象 mBlueService = new BluetoothService(mHandler); } //重写setMenuVisibility方法,不然会出现叠层的现象 public void setMenuVisibility(boolean menuVisibility) { super.setMenuVisibility(menuVisibility); if (this.getView() != null) { this.getView().setVisibility(menuVisibility ? View.VISIBLE : View.GONE); } } } ``` 当我把周围的设备搜索出来,准备连接的时候,就给我报错如下:Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.bluetooth.BluetoothDevice android.bluetooth.BluetoothAdapter.getRemoteDevice(java.lang.String)' on a null object reference 出错的这段代码为:BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address); 我通过日志打印发现明明address是有值的啊,可是怎么就出这种错误呢,求各位大神指导一下啊! c币不多,能回答上的我追加财富。

求教Android中RecyclerView的ViewHolder的一些问题

初学Android,看了一些代码,基本上适配器的代码都是这么写的 ``` public class NewAdapter extends RecyclerView.Adapter <NewAdapter.ViewHolder> { private List<String> data; static class ViewHolder extends RecyclerView.ViewHolder { Button number; Button name; public ViewHolder(View view) { super(view); number=view.findViewById(R.id.text1); name=view.findViewById(R.id.text2); } } public NewAdapter(List<String> data) { this.data=data; } @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.recycler,parent,false); ViewHolder holder=new ViewHolder(view); return holder; } @Override public void onBindViewHolder(ViewHolder holder, int position) { String name=data.get(position); holder.number.setText(String.valueOf(position)); holder.name.setText(name); } @Override public int getItemCount() { return data.size(); } } ``` 代码中有个ViewHolder,都说ViewHolder可以加载Item的布局可以节省findViewByID操作。但是每次当滚动需要显示新的Item都会调用onCreateViewHolder,而每次调用都会创建一个新View让ViewHolder加载,这样不就没有节省吗? 还有就是不太明白onCreateViewHolder的返回值是用到onBindViewHolder上了么。 那样要滚动显示一个Item的步骤是不是先调用onCreateViewHolder,创建出一个ViewHolder,其中包含着要显示的Item中的的Button,TextView一类的实例。然后将这个ViewHolder作为参数调用onBindViewHolder,然后将Item中的Button,TextView置上数据??

安卓程序提示java.lang.IndexOutOfBoundsException

这是java代码 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button btn=(Button) this.findViewById(R.id.btn3); SpannableString span=new SpannableString("Lift"); Bitmap bit= BitmapFactory.decodeResource(getResources(),R.drawable.image2); ImageSpan image=new ImageSpan(bit,DynamicDrawableSpan.ALIGN_BOTTOM); span.setSpan(image,0,4, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); btn.append(span); btn.append("我的按钮"); } 这是布局 <Button android:layout_width="150sp" android:layout_height="150sp" android:id="@+id/btn3" android:layout_below="@+id/btn2"/>

关于安卓页面跳转的问题

做了两个页面与页面跳转按钮,二页面想使用ListActivity,但是继承了ListActivity类后闪退 继承Activity时运行正常,但不能看到List效果,请大神帮忙看下代码,感谢 DEBUG 线程 [main](已暂挂(异常 RuntimeException)) ActivityThread.performLaunchActivity(ActivityThread$ActivityClientRecord, Intent) 行: 3254 ActivityThread.handleLaunchActivity(ActivityThread$ActivityClientRecord, Intent) 行: 3350 ActivityThread.access$1100(ActivityThread, ActivityThread$ActivityClientRecord, Intent) 行: 223 ActivityThread$H.handleMessage(Message) 行: 1794 ActivityThread$H(Handler).dispatchMessage(Message) 行: 102 Looper.loop() 行: 148 ActivityThread.main(String[]) 行: 7224 Method.invoke(Object, Object...) 行: 不可用 [本机方法] ZygoteInit$MethodAndArgsCaller.run() 行: 1230 ZygoteInit.main(String[]) 行: 1120 报错日志 04-11 10:03:01.957: E/MotionRecognitionManager(30956): mSContextService = android.hardware.scontext.ISContextService$Stub$Proxy@b530bca 04-11 10:03:01.967: E/MotionRecognitionManager(30956): motionService = com.samsung.android.motion.IMotionRecognitionService$Stub$Proxy@82fc13b 04-11 10:03:01.967: E/MotionRecognitionManager(30956): motionService = com.samsung.android.motion.IMotionRecognitionService$Stub$Proxy@82fc13b 04-11 10:03:01.967: D/AndroidRuntime(30956): Shutting down VM 04-11 10:03:01.967: E/AndroidRuntime(30956): FATAL EXCEPTION: main 04-11 10:03:01.967: E/AndroidRuntime(30956): Process: com.example.audiorecord, PID: 30956 04-11 10:03:01.967: E/AndroidRuntime(30956): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.audiorecord/com.example.audiorecord.Activity02}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list' 04-11 10:03:01.967: E/AndroidRuntime(30956): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3254) 04-11 10:03:01.967: E/AndroidRuntime(30956): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3350) 04-11 10:03:01.967: E/AndroidRuntime(30956): at android.app.ActivityThread.access$1100(ActivityThread.java:223) 04-11 10:03:01.967: E/AndroidRuntime(30956): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) 04-11 10:03:01.967: E/AndroidRuntime(30956): at android.os.Handler.dispatchMessage(Handler.java:102) 04-11 10:03:01.967: E/AndroidRuntime(30956): at android.os.Looper.loop(Looper.java:148) 04-11 10:03:01.967: E/AndroidRuntime(30956): at android.app.ActivityThread.main(ActivityThread.java:7224) 04-11 10:03:01.967: E/AndroidRuntime(30956): at java.lang.reflect.Method.invoke(Native Method) 04-11 10:03:01.967: E/AndroidRuntime(30956): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 04-11 10:03:01.967: E/AndroidRuntime(30956): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 04-11 10:03:01.967: E/AndroidRuntime(30956): Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list' 04-11 10:03:01.967: E/AndroidRuntime(30956): at android.app.ListActivity.onContentChanged(ListActivity.java:243) 04-11 10:03:01.967: E/AndroidRuntime(30956): at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:479) 04-11 10:03:01.967: E/AndroidRuntime(30956): at android.app.Activity.setContentView(Activity.java:2388) 04-11 10:03:01.967: E/AndroidRuntime(30956): at com.example.audiorecord.Activity02.onCreate(Activity02.java:38) 04-11 10:03:01.967: E/AndroidRuntime(30956): at android.app.Activity.performCreate(Activity.java:6877) 04-11 10:03:01.967: E/AndroidRuntime(30956): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1136) 04-11 10:03:01.967: E/AndroidRuntime(30956): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3207) 04-11 10:03:01.967: E/AndroidRuntime(30956): ... 9 more Activity1: package com.example.audiorecord; import java.io.File; import java.io.IOException; import android.app.Activity; import android.media.MediaPlayer; import android.media.MediaRecorder; import android.os.Bundle; import android.os.Environment; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.content.Intent; public class RecordActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); super.onCreate(savedInstanceState); /* 设置显示main.xml布局*/ setContentView(R.layout.main); /* findViewById(R.id.button1)取得布局main.xml中的button1 */ Button button = (Button) findViewById(R.id.button1); /* 监听button的事件信息*/ button.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { /* 新建一个Intent对象*/ Intent intent = new Intent(); /* 指定intent要启动的类*/ intent.setClass(RecordActivity.this, Activity02.class); /* 启动一个新的Activity */ startActivity(intent); /* 关闭当前的Activity */ RecordActivity.this.finish(); } }); } } Activity2 package com.example.audiorecord; import java.io.File; import java.util.ArrayList; import java.util.List; import android.app.Activity; import android.app.AlertDialog; import android.app.ListActivity; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.ListView; import android.widget.TextView; public class Activity02 extends ListActivity{ //声明 private List<String> items = null;//存放名称 private List<String> paths = null;//存放路径 private String rootPath = "/"; private TextView tv; private Button Back; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /* 设置显示main2布局*/ setContentView(R.layout.main2); /* findViewById(R.id.button2)取得布局main.xml中的button2 */ /* 监听button的事件信息*/ tv = (TextView) this.findViewById(R.id.TextView); this.getFileDir(rootPath);//获取rootPath目录下的文件. Back = (Button) findViewById(R.id.back); Back.setOnClickListener(new BackListener()); } class BackListener implements OnClickListener { public void onClick(View v) { Intent intent = new Intent(); /* 指定intent要启动的类*/ intent.setClass(Activity02.this, RecordActivity.class); /* 启动一个新的Activity */ startActivity(intent); /* 关闭当前的Activity */ Activity02.this.finish(); } } public void getFileDir(String filePath) { try{ this.tv.setText("当前路径:"+filePath);// 设置当前所在路径 items = new ArrayList<String>(); paths = new ArrayList<String>(); File f = new File(filePath); File[] files = f.listFiles();// 列出所有文件 // 如果不是根目录,则列出返回根目录和上一目录选项 if (!filePath.equals(rootPath)) { items.add("返回根目录"); paths.add(rootPath); items.add("返回上一层目录"); paths.add(f.getParent()); } // 将所有文件存入list中 if(files != null){ int count = files.length;// 文件个数 for (int i = 0; i < count; i++) { File file = files[i]; items.add(file.getName()); paths.add(file.getPath()); } } ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, items); this.setListAdapter(adapter); }catch(Exception ex){ ex.printStackTrace(); } } @Override protected void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); String path = paths.get(position); File file = new File(path); //如果是文件夹就继续分解 if(file.isDirectory()){ this.getFileDir(path); }else{ new AlertDialog.Builder(this).setTitle("提示").setMessage(file.getName()+" 是一个文件!").setPositiveButton("OK", new DialogInterface.OnClickListener(){ public void onClick(DialogInterface dialog, int which) { } }).show(); } }} MANIFEST <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.audiorecord" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="4" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" /> <uses-permission android:name="android.permission.RECORD_AUDIO" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:name=".RecordActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".Activity02"></activity> </application> </manifest>

android studio运行报下列错误

1.貌似有问题的代码 package com.example.coolweather; import android.app.Fragment; import android.app.ProgressDialog; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; import com.example.coolweather.db.City; import com.example.coolweather.db.County; import com.example.coolweather.db.Province; import com.example.coolweather.util.HttpUtil; import com.example.coolweather.util.Utility; import org.litepal.crud.DataSupport; import java.io.IOException; import java.util.ArrayList; import java.util.List; import okhttp3.Call; import okhttp3.Callback; import okhttp3.Response; /** * Created by Airth on 2019/5/10. */ public class ChooseAreaFragment extends Fragment { public static final int LEVEL_PROVINCE=0; public static final int LEVEL_CITY=1; public static final int LEVEL_COUNTY=2; private ProgressDialog progressDialog; private TextView titleText; private Button backButton; private ListView listView; private ArrayAdapter<String> adapter; private List<String> dataList = new ArrayList<>(); private int currentLevel; //当前被选中的级别 private Province selectedProvince;//被选中的省份 private City selectedCity;//被选中的城市 private List<Province> provinceList;//省列表 private List<City> cityList;//市列表 private List<County> countyList ;//县列表 /*获取控件实例id*/ @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { Log.d("ChooseAreaFragment","onCreateView"); View view = inflater.inflate(R.layout.choose_area,container,false); titleText = (TextView)view.findViewById(R.id.title_text); //获取标题栏文本id backButton = (Button) view.findViewById(R.id.back_button); //获取标题栏id listView = (ListView)view.findViewById(R.id.list_view); //获取Item列表id //获取ArrayAdapter对象 adapter =new ArrayAdapter<>(getContext(), android.R.layout.simple_list_item_1, dataList); listView.setAdapter(adapter);//设置并初始化适配器 return view;//将视图返回 } /*点击事件集合*/ @Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { Log.d("ChooseAreaFragment","onActivityCreated"); super.onActivityCreated(savedInstanceState); //列表任意一栏被点击,则... listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Log.d("ChooseAreaFragment","列表被点了的..."); if (currentLevel == LEVEL_PROVINCE){ //当前选中的级别为省份时 selectedProvince = provinceList.get(position); //当前点击为选中状态 queryCities();//查询市的方法 } else if (currentLevel == LEVEL_CITY){ selectedCity = cityList.get(position); queryCounties(); } } }); backButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (currentLevel == LEVEL_COUNTY){ queryCities(); } else if (currentLevel == LEVEL_CITY){ queryProvinces(); } } }); queryProvinces(); } private void queryCities() { titleText.setText(selectedProvince.getProvinceName()); //设置市的标题内容 backButton.setVisibility(View.VISIBLE); //设置返回按钮可见 //查询被选中的省份城市的市区 cityList = DataSupport.where("provinceid=?",String.valueOf(selectedProvince. getId())).find(City.class); Log.d("ChooseAreaFragment","市级"); if (cityList.size()>0){ //如果省列表不为空,则... dataList.clear(); for (City city:cityList){ //遍历每一份省的市级城市 dataList.add(city.getCityName()); //添加到数据列表中 } adapter.notifyDataSetChanged();//通知适配器数据更新了 listView.setSelection(0); currentLevel = LEVEL_CITY; } else{ int provinceCode = selectedProvince.getProvinceCode(); //获取被选取省级代码 String address = "http://guolin.tech/api/china/"+provinceCode;//获取被选取地区的网络地址 Log.d("ChooseAreaFragment","准备在网络中获取地址信息"); queryFromServer(address,"city"); // 在网络中查询 } } /*根据传入的地址和类型从服务器查询省市县数据*/ private void queryFromServer(String adress, final String type) { showProgressDialog(); // 发送一条网络请求 HttpUtil.sendOKHttpRequest(adress, new Callback() { //请求加载失败 @Override public void onFailure(Call call, IOException e) { //通过runOnUiThread方法回到主线程逻辑 getActivity().runOnUiThread(new Runnable() { @Override public void run() { closeProgressDialog(); Toast.makeText(getContext(),"加载失败",Toast.LENGTH_SHORT).show(); } }); } @Override public void onResponse(Call call, Response response) throws IOException { Log.d("ChooseAreaFragment","加载地区信息..."); String responseText = response.body().string(); boolean result = false; if ("province".equals(type)){ result = Utility.handleProvinceResponse(responseText); } else if ("city".equals(type)){ result = Utility.handleCityResponse(responseText,selectedProvince.getId()); } else if ("county".equals(type)){ result = Utility.handleCountyResponse(responseText, selectedCity.getId()); } if (result) { getActivity().runOnUiThread(new Runnable() { @Override public void run() { Log.d("ChooseAreaFragment","开启线程更新UI"); closeProgressDialog(); if ("province".equals(type)){ queryProvinces(); } else if ("city".equals(type)){ queryCities(); } else if ("county".equals(type)){ queryCounties(); } } }); } if ("city".equals(type)){ result = Utility.handleProvinceResponse(responseText); } if ("county".equals(type)){ result = Utility.handleProvinceResponse(responseText); } } }); } /*显示进度对话框*/ private void showProgressDialog() { if (progressDialog==null){ progressDialog = new ProgressDialog(getActivity()); progressDialog.setMessage("正在加载..."); progressDialog.setCanceledOnTouchOutside(false); } progressDialog.show(); } private void queryCounties() { titleText.setText(selectedCity.getCityName()); backButton.setVisibility(View.VISIBLE); countyList = DataSupport.where("cityid = ?", String.valueOf(selectedCity.getId())).find(County.class); if (countyList.size()>0){ dataList.clear(); for (County county:countyList){ dataList.add(county.getCountyName()); } adapter.notifyDataSetChanged(); listView.setSelection(0); currentLevel=LEVEL_COUNTY; } else { int provinceCode = selectedProvince.getProvinceCode(); int cityCode = selectedCity.getCityCode(); String address = "http://guolin.tech/api/china/"+provinceCode+"/"+cityCode; queryFromServer(address,"county"); } } /*全国所有的省,优先查询数据库,如果没有再去服务器查询*/ private void queryProvinces() { titleText.setText("中国"); Log.d("ChooseAreaFragment","查询省中..."); backButton.setVisibility(View.GONE); provinceList = DataSupport.findAll(Province.class); if (provinceList.size()>0){ dataList.clear(); for (Province province:provinceList){ dataList.add(province.getProvinceName()); } adapter.notifyDataSetChanged(); listView.setSelection(0); currentLevel = LEVEL_PROVINCE; } else { Log.d("ChooseAreaFragment","服务器查询省中..."); String address = "http://guolin.tech/api/china"; queryFromServer(address,"province"); } } private void closeProgressDialog() { if (progressDialog!=null){ progressDialog.dismiss(); } } } 2.这是报错日志 ![图片说明](https://img-ask.csdn.net/upload/201905/10/1557481080_879893.png)

Android activity跳转闪退

新手写代码,求大神指导。扫描垃圾页面跳转到清理垃圾页面时闪退 报错信息如下 E/AndroidRuntime: FATAL EXCEPTION: Thread-6 Process: com.itheima.mobilesafe, PID: 19827 java.lang.NullPointerException: Attempt to invoke interface method 'java.util.Iterator java.util.List.iterator()' on a null object reference at com.itheima.mobilesafe.clean.CleanRubbishActivity$2.run(CleanRubbishActivity.java:125) E/MQSEventManagerDelegate: failed to get MQSService. I/Process: Sending signal. PID: 19827 SIG: 9 Application terminated. 125行是这里 ``` for (RubbishInfo info:mRubbishInfos) ``` 又看了一下,大概是接收数据的时候出现了问题 ``` mRubbishInfos= (List<RubbishInfo>) intent.getSerializableExtra("rubbishInfos"); ``` ![图片说明](https://img-ask.csdn.net/upload/202006/14/1592122391_54904.png) 我搜了一下解决方法有两个,一个是加unchecked注解,这种好像解决不了问题,另外一种是类型检查,但我不知道怎么改,有大神指点吗。

运行到setContentView这里崩溃了

这是第一行代码里面的一个项目,运行后崩溃: ![图片说明](https://img-ask.csdn.net/upload/201702/12/1486848687_748230.jpg) MainActivity.java ``` package com.example.newsapp; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.Window; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_main); } @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; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } } ``` News.java ``` package com.example.newsapp; public class News { private String title; private String content; public String getTitle() { return title; } public void setTitle(String title) { this.title=title; } public String getContent() { return content; } public void setContent(String content) { this.content=content; } } ``` NewsAdapter.java ``` package com.example.newsapp; import java.util.List; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.TextView; public class NewsAdapter extends ArrayAdapter<News> { private int resourceId; public NewsAdapter(Context context,int textViewResourceId,List<News> objects) { super(context,textViewResourceId,objects); resourceId=textViewResourceId; } @Override public View getView(int position,View convertView,ViewGroup parent) { News news=getItem(position); View view; if (convertView==null) { view=LayoutInflater.from(getContext()).inflate(resourceId,null); } else { view=convertView; } TextView newsTitleText=(TextView)view.findViewById(R.id.news_title); newsTitleText.setText(news.getTitle()); return view; } } ``` NewsContentActivity.java ``` package com.example.newsapp; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.view.Window; public class NewsContentActivity extends FragmentActivity { public static void actionStart(Context context,String newsTitle,String newsContent) { Intent intent=new Intent(context,NewsContentActivity.class ); intent.putExtra("news_title",newsTitle); intent.putExtra("news_content",newsContent); context.startActivity(intent); } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.news_content); FragmentManager fragmentManager=getSupportFragmentManager(); String newsTitle=getIntent().getStringExtra("news_title"); String newsContent=getIntent().getStringExtra("news_content"); NewsContentFragment newsContentFragment=(NewsContentFragment)fragmentManager.findFragmentById(R.id.news_content_fragment); newsContentFragment.refresh(newsTitle,newsContent); } } ``` NewsContentFragment.java ``` package com.example.newsapp; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; public class NewsContentFragment extends Fragment { private View view; @Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState) { view=inflater.inflate(R.layout.news_content_frag,container,false ); return view; } public void refresh(String newsTitle,String newsContent) { View visibilityLayout=view.findViewById(R.id.visibility_layout); visibilityLayout.setVisibility(View.VISIBLE); TextView newsTitleText=(TextView)view.findViewById(R.id.news_title); TextView newsContentText=(TextView)view.findViewById(R.id.news_content); newsTitleText.setText(newsTitle); newsContentText.setText(newsContent); } } ``` NewsTitleFragment.java ``` package com.example.newsapp; import java.util.ArrayList; import java.util.List; import android.app.Activity; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ListView; public class NewsTitleFragment extends Fragment implements OnItemClickListener { private ListView newsTitleListView; private List<News> newsList; private NewsAdapter adapter; private boolean isTwoPane; @Override public void onAttach(Activity activity) { super.onAttach(activity); newsList=getNews(); adapter=new NewsAdapter(activity,R.layout.news_item,newsList); } @Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState) { View view=inflater.inflate(R.layout.news_title_frag,container,false ); newsTitleListView=(ListView)view.findViewById(R.id.news_title_list_view); newsTitleListView.setAdapter(adapter); newsTitleListView.setOnItemClickListener(this ); return view; } @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (getActivity().findViewById(R.id.news_content_layout)!=null ) isTwoPane=true; else isTwoPane=false; } @Override public void onItemClick(AdapterView<?> parent,View view,int position,long id) { News news=newsList.get(position); if (isTwoPane) { NewsContentFragment newsContentFragment=(NewsContentFragment)getFragmentManager().findFragmentById(R.id.news_content_fragment); newsContentFragment.refresh(news.getTitle(),news.getContent()); } else { NewsContentActivity.actionStart(getActivity(),news.getTitle(),news.getContent()); } } private List<News> getNews() { List<News> newsList=new ArrayList<News>(); News news1=new News(); news1.setTitle("标题"); news1.setContent("内容"); newsList.add(news1); News news2=new News(); news2.setTitle("日记"); news2.setContent("去旅游"); newsList.add(news2); return newsList; } } ```

autocomplete text view 不能运行的问题

当在程序的联系人列表中搜索联系人时,我想使用 autocompletetextview,但是成行执行不了。 Search.java: public class Search extends ListActivity { private static int[] TO = {R.id.name }; private static String[] FROM = {DbConstants.NAME, DbConstants.PHONE, DbConstants.EMAIL,_ID}; private Button sButton; private ListView lv1; private static SQLiteDatabase db; private DbCreate contacts; private Cursor cursor; private AutoCompleteTextView searchText; protected SimpleCursorAdapter adapter; protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.search); ArrayAdapter<String> adapter=new ArrayAdapter<String>(this,android.R.layout.simple_dropdown_item_1line,new String[] {DbConstants.NAME}); searchText=(AutoCompleteTextView)findViewById(R.id.searchtext); searchText.setAdapter(adapter); sButton=(Button)findViewById(R.id.searchButton); sButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub showDatabaseContent(); lv1 = getListView(); lv1.setTextFilterEnabled(true); } }); } search.xml: <?xml version="1.0" encoding="utf-8" ?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content"> <AutoCompleteTextView android:id="@+id/searchtext" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:hint="@string/searchDefault"> <requestFocus /> </AutoCompleteTextView> <Button android:id="@+id/searchButton" android:icon="@drawable/search" android:text="Search" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout> <TextView android:id="@android:id/empty" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/empt" /> <ListView android:id="@android:id/list" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </LinearL ayout> 当我点击 search button 查找时会出错,其余时候都不出错。当我键入一个名称时也没有反应,问题出在哪里啊?

自定义单选列表对话框单选后item值传递问题

我自定义了一个单选列表的对话框,想要选择一行数据后点击确定按钮再对这行数据进行相应操作, 但是我发现我现在的实现是不论点击哪行传进去的itemPosition都是最初默认的0; 相应部分代码见下: ``` //自定义Dialog public class CustomDialog extends Dialog { public CustomDialog(Context context) { super(context); } public CustomDialog(Context context, int theme) { super(context, theme); } public static class Builder { private Context context; private String title; private String positiveButtonText; private String negativeButtonText; private View contentView; private ArrayList<String> mListItem; private BaseAdapter mAdapter; private int mClickedDialogEntryIndex; private DialogInterface.OnClickListener positiveButtonClickListener; private DialogInterface.OnClickListener negativeButtonClickListener; public Builder(Context context) { this.context = context; } /** * Set the Dialog title from String * * @param title * @return */ public Builder setTitle(String title) { this.title = title; return this; } public Builder setContentView(View v) { this.contentView = v; return this; } public Builder setPositiveButton(String positiveButtonText, DialogInterface.OnClickListener listener) { this.positiveButtonText = positiveButtonText; this.positiveButtonClickListener = listener; return this; } public Builder setNegativeButton(int negativeButtonText, DialogInterface.OnClickListener listener) { this.negativeButtonText = (String) context .getText(negativeButtonText); this.negativeButtonClickListener = listener; return this; } public Builder setNegativeButton(String negativeButtonText, DialogInterface.OnClickListener listener) { this.negativeButtonText = negativeButtonText; this.negativeButtonClickListener = listener; return this; } public ArrayList<String> getItems() { return mListItem; } public Builder setItems(ArrayList<String> mListItem) { this.mListItem = mListItem; return this; } public Builder setSingleChoiceItems(ArrayList<String> mPairedDevicesList, int checkedItem, final OnClickListener listener) { this.mListItem = mPairedDevicesList; this.positiveButtonClickListener = listener; this.mClickedDialogEntryIndex = checkedItem; return this; } public Builder setSingleChoiceItems(BaseAdapter adapter, int checkedItem, final OnClickListener listener) { this.mAdapter = adapter; this.positiveButtonClickListener = listener; this.mClickedDialogEntryIndex = checkedItem; return this; } public CustomDialog create() { LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); // instantiate the dialog with the custom Theme final CustomDialog dialog = new CustomDialog(context,R.style.Dialog); View layout = inflater.inflate(R.layout.dialog_normal_layout, null); dialog.addContentView(layout, new LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); /*if(mListItem == null){ throw new RuntimeException("Entries should not be empty"); }*/ if(mAdapter == null){ throw new RuntimeException("Entries should not be empty"); } ListView lvListItem = (ListView) layout.findViewById(R.id.lvListItem); lvListItem.setAdapter(mAdapter); //lvListItem.setAdapter(new ArrayAdapter(context, R.layout.simple_list_item_single_choice, R.id.text1, mListItem)); lvListItem.setChoiceMode(ListView.CHOICE_MODE_SINGLE); lvListItem.setItemChecked(mClickedDialogEntryIndex, true); lvListItem.setSelection(mClickedDialogEntryIndex); // set the cancel button if (negativeButtonText != null) { ((Button) layout.findViewById(R.id.cancelBtn)) .setText(negativeButtonText); if (negativeButtonClickListener != null) { ((Button) layout.findViewById(R.id.cancelBtn)) .setOnClickListener(new View.OnClickListener() { public void onClick(View v) { negativeButtonClickListener.onClick(dialog, DialogInterface.BUTTON_NEGATIVE); } }); }else{ ((Button) layout.findViewById(R.id.cancelBtn)).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub dialog.dismiss(); } }); } } else { // if no confirm button just set the visibility to GONE layout.findViewById(R.id.cancelBtn).setVisibility( View.GONE); } if(positiveButtonText != null){ ((Button) layout.findViewById(R.id.connectBtn)) .setText(positiveButtonText); if (positiveButtonClickListener != null) { ((Button) layout.findViewById(R.id.connectBtn)) .setOnClickListener(new View.OnClickListener() { public void onClick(View v) { positiveButtonClickListener.onClick(dialog, mClickedDialogEntryIndex); } }); }else{ ((Button) layout.findViewById(R.id.connectBtn)).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub dialog.dismiss(); } }); } }else { // if no confirm button just set the visibility to GONE layout.findViewById(R.id.connectBtn).setVisibility( View.GONE); } if (contentView != null) { // if no message set // add the contentView to the dialog body ((LinearLayout) layout.findViewById(R.id.content)) .removeAllViews(); ((LinearLayout) layout.findViewById(R.id.content)).addView( contentView, new LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); } dialog.setContentView(layout); return dialog; } } } ``` ``` //调用自定义dialog final CustomDialog myDialog = new CustomDialog.Builder(getActivity()) .setTitle(getString(R.string.btdialog_title)) .setPositiveButton(getString(R.string.connect), btnListener) .setNegativeButton(getString(R.string.cancel), null) .setSingleChoiceItems(btAdapter, -1, choiceListener) .create(); myDialog.show(); ``` 其中choiceListener的实现 ``` private class ChoiceOnClickListener implements DialogInterface.OnClickListener{ private int which = 0; public void onClick(DialogInterface dialogInteface, int which){ this.which = which; } public int getWhich(){ return which; } } final ChoiceOnClickListener choiceListener = new ChoiceOnClickListener(); ``` 这里就是不管选择列表中的哪一行,那个我想要的which值一直都是初始的0,为什么呢?

请教一个Activity跳转到另外一个Activity失败的问题

package com.example.t; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; public class LoginActivity extends Activity { private EditText mAccount; private EditText mPwd; private Button mLoginButton; private View loginView; private View loginSuccessView; private TextView loginSuccessShow; private LoginDataManager mUserDataManager; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.loginpage); mAccount=(EditText) findViewById(R.id.login_edit_account); mPwd = (EditText) findViewById(R.id.login_edit_pwd); mLoginButton = (Button) findViewById(R.id.login_btn_login); loginView=findViewById(R.id.login_view); loginSuccessView=findViewById(R.id.login_success_view); loginSuccessShow=(TextView) findViewById(R.id.login_success_show); mLoginButton.setOnClickListener(mListener); if (mUserDataManager == null) { mUserDataManager = new LoginDataManager(this); mUserDataManager.openDataBase(); } } OnClickListener mListener = new OnClickListener() { public void onClick(View v) { int id=v.getId(); if( id==R.id.login_btn_login){ login(); } } }; public void login() { if (isUserNameAndPwdValid()) { String userName = mAccount.getText().toString().trim(); String userPwd = mPwd.getText().toString().trim(); int result=mUserDataManager.findUserByNameAndPwd(userName, userPwd); if(result==1){ //login success loginView.setVisibility(View.GONE); loginSuccessView.setVisibility(View.VISIBLE); loginSuccessShow.setText(getString(R.string.user_login_sucess, userName)); Toast.makeText(this, getString(R.string.login_sucess), Toast.LENGTH_SHORT).show(); }else if(result==0){ //login failed,user does't exist Toast.makeText(this, getString(R.string.login_fail), Toast.LENGTH_SHORT).show(); } } } public void register() { if (isUserNameAndPwdValid()) { String userName = mAccount.getText().toString().trim(); String userPwd = mPwd.getText().toString().trim(); //check if user name is already exist int count=mUserDataManager.findUserByName(userName); if(count>0){ Toast.makeText(this, getString(R.string.name_already_exist, userName), Toast.LENGTH_SHORT).show(); return ; } } } public boolean isUserNameAndPwdValid() { if (mAccount.getText().toString().trim().equals("")) { Toast.makeText(this, getString(R.string.account_empty), Toast.LENGTH_SHORT).show(); return false; } else if (mPwd.getText().toString().trim().equals("")) { Toast.makeText(this, getString(R.string.pwd_empty), Toast.LENGTH_SHORT).show(); return false; } return true; } @Override protected void onResume() { if (mUserDataManager == null) { mUserDataManager = new LoginDataManager(this); mUserDataManager.openDataBase(); } super.onResume(); } @Override protected void onDestroy() { super.onDestroy(); } @Override protected void onPause() { if (mUserDataManager != null) { mUserDataManager.closeDataBase(); mUserDataManager = null; } super.onPause(); } } 另一个 package com.example.t; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.Window; import android.widget.AdapterView; import android.widget.GridView; import android.widget.SimpleAdapter; import android.widget.AdapterView.OnItemClickListener; /** * @author Administrator * @description 首页 */ public class HomePageActivity extends Activity implements OnItemClickListener { private boolean[] isPermitted; int drawableitems[] = { R.drawable.aa,R.drawable.bb,R.drawable.cc,R.drawable.dd,R.drawable.ee,R.drawable.ff,R.drawable.gg}; String[] itemsnames = { "最热单品","时尚饰品","珠宝首饰", "品质手表","潮流眼镜","绅士配件","DIY" }; @Override protected void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(savedInstanceState); setContentView(R.layout.home); GridView gridview = (GridView) findViewById(R.id.GridView); List<Map<String, Object>> itemList = new ArrayList<Map<String, Object>>(); for (int i = 0; i < itemsnames.length; i++) { Map<String, Object> map = new HashMap<String, Object>(); map.put("ItemImage", drawableitems[i]); map.put("ItemText", itemsnames[i]); itemList.add(map); } SimpleAdapter saMenuItem = new SimpleAdapter(this, itemList, // 数据源 R.layout.homeitems, // xml实现 new String[] { "ItemImage", "ItemText" }, // 对应map的Key new int[] { R.id.ItemImage, R.id.ItemText }); // 对应R的Id // 添加Item到网格中 gridview.setAdapter(saMenuItem); gridview.setOnItemClickListener(this); //permit setting isPermitted = new boolean[saMenuItem.getCount()]; } @Override public void onItemClick(AdapterView<?> adapter, View view, int position, long id) { System.out.println("id:" + id); System.out.println("position:" + position); // String[] itemsnames = { "最热单品","时尚饰品","珠宝首饰", "品质手表","潮流眼镜","绅士配件","DIY" }; if (position == 0) { System.out.println("最热单品"); Intent intent1 = new Intent(this, HotActivity.class); startActivity(intent1); } if (position == 1) { System.out.println("时尚饰品"); Intent intent = new Intent(this, FashionActivity.class); startActivity(intent); } if (position == 2) { System.out.println("珠宝首饰"); Intent intent = new Intent(this, JewelryActivity.class); startActivity(intent); } if (position == 3) { System.out.println("品质手表"); Intent intent = new Intent(this, WatchActivity.class); startActivity(intent); } if (position == 4) { System.out.println("潮流眼镜"); Intent intent = new Intent(this, GlassesActivity.class); startActivity(intent); } if (position == 5) { System.out.println("绅士配件"); Intent intent = new Intent(this,GentryActivity.class); startActivity(intent); } if (position == 6) { System.out.println("DIY"); Intent intent = new Intent(HomePageActivity.this,DiyActicity.class); startActivity(intent); } } } 之前可能发错了,不好意思 是不是缺少了一些代码,求补充~

Python数据挖掘简易入门

&nbsp; &nbsp; &nbsp; &nbsp; 本课程为Python数据挖掘方向的入门课程,课程主要以真实数据为基础,详细介绍数据挖掘入门的流程和使用Python实现pandas与numpy在数据挖掘方向的运用,并深入学习如何运用scikit-learn调用常用的数据挖掘算法解决数据挖掘问题,为进一步深入学习数据挖掘打下扎实的基础。

HoloLens2开发入门教程

本课程为HoloLens2开发入门教程,讲解部署开发环境,安装VS2019,Unity版本,Windows SDK,创建Unity项目,讲解如何使用MRTK,编辑器模拟手势交互,打包VS工程并编译部署应用到HoloLens上等。

2019 Python开发者日-培训

本次活动将秉承“只讲技术,拒绝空谈”的理念,邀请十余位身处一线的Python技术专家,重点围绕Web开发、自动化运维、数据分析、人工智能等技术模块,分享真实生产环境中使用Python应对IT挑战的真知灼见。此外,针对不同层次的开发者,大会还安排了深度培训实操环节,为开发者们带来更多深度实战的机会。

Only老K说-爬取妹子图片(简单入门)

安装第三方请求库 requests 被网站禁止了访问 原因是我们是Python过来的 重新给一段 可能还是存在用不了,使用网页的 编写代码 上面注意看匹配内容 User-Agent:请求对象 AppleWebKit:请求内核 Chrome浏览器 //请求网页 import requests import re //正则表达式 就是去不规则的网页里面提取有规律的信息 headers = { 'User-Agent':'存放浏览器里面的' } response = requests.get

2020_五一数学建模_C题_整理后的数据.zip

该数据是我的程序读取的数据,仅供参考,问题的解决方案:https://blog.csdn.net/qq_41228463/article/details/105993051

R语言入门基础

本课程旨在帮助学习者快速入门R语言: 课程系统详细地介绍了使用R语言进行数据处理的基本思路和方法。 课程能够帮助初学者快速入门数据处理。 课程通过大量的案例详细地介绍了如何使用R语言进行数据分析和处理 课程操作实际案例教学,通过编写代码演示R语言的基本使用方法和技巧

人才招聘系统PHP+MySQL源码

PHP 5.0及以上 + MySQL 5.0及以上 开发的人才招聘系统完全可运行源码,按照操作说明简单配置即可运行。学习PHPWEB应用的完整系统程序源码。

Java基础知识面试题(2020最新版)

文章目录Java概述何为编程什么是Javajdk1.5之后的三大版本JVM、JRE和JDK的关系什么是跨平台性?原理是什么Java语言有哪些特点什么是字节码?采用字节码的最大好处是什么什么是Java程序的主类?应用程序和小程序的主类有何不同?Java应用程序与小程序之间有那些差别?Java和C++的区别Oracle JDK 和 OpenJDK 的对比基础语法数据类型Java有哪些数据类型switc...

python可视化分析(matplotlib、seaborn、ggplot2)

python可视化分析总结(matplotlib、seaborn、ggplot)一、matplotlib库1、基本绘图命令3、图形参数设置4、特殊统计图的绘制4.1 数学函数图4.2 气泡图4.1 三维曲面图二、seaborn库1、常用统计图1.1 箱线图1.2 小提琴图1.3 点图1.4 条图与计数图1.5 分组图1.6 概率分布图2、联合图3、配对图三、ggplot库1、图层画法+常用图形2、快速绘图 一、matplotlib库 1、基本绘图命令 import matplotlib.pyplot as

Vue.js 2.0之全家桶系列视频课程

基于新的Vue.js 2.3版本, 目前新全的Vue.js教学视频,让你少走弯路,直达技术前沿! 1. 包含Vue.js全家桶(vue.js、vue-router、axios、vuex、vue-cli、webpack、ElementUI等) 2. 采用笔记+代码案例的形式讲解,通俗易懂

初级玩转Linux+Ubuntu(嵌入式开发基础课程)

课程主要面向嵌入式Linux初学者、工程师、学生 主要从一下几方面进行讲解: 1.linux学习路线、基本命令、高级命令 2.shell、vi及vim入门讲解 3.软件安装下载、NFS、Samba、FTP等服务器配置及使用

人工智能-计算机视觉实战之路(必备算法+深度学习+项目实战)

系列课程主要分为3大阶段:(1)首先掌握计算机视觉必备算法原理,结合Opencv进行学习与练手,通过实际视项目进行案例应用展示。(2)进军当下最火的深度学习进行视觉任务实战,掌握深度学习中必备算法原理与网络模型架构。(3)结合经典深度学习框架与实战项目进行实战,基于真实数据集展开业务分析与建模实战。整体风格通俗易懂,项目驱动学习与就业面试。 建议同学们按照下列顺序来进行学习:1.Python入门视频课程 2.Opencv计算机视觉实战(Python版) 3.深度学习框架-PyTorch实战/人工智能框架实战精讲:Keras项目 4.Python-深度学习-物体检测实战 5.后续实战课程按照自己喜好选择就可以

【大总结2】大学两年,写了这篇几十万字的干货总结

本文十天后设置为粉丝可见,喜欢的提前关注 不要白嫖请点赞 不要白嫖请点赞 不要白嫖请点赞 文中提到的书我都有电子版,可以评论邮箱发给你。 文中提到的书我都有电子版,可以评论邮箱发给你。 文中提到的书我都有电子版,可以评论邮箱发给你。 本篇文章应该算是Java后端开发技术栈的,但是大部分是基础知识,所以我觉得对任何方向都是有用的。 1、数据结构 数据结构是计算机存储、...

lena全身原图(非256*256版本,而是全身原图)

lena全身原图(非256*256版本,而是全身原图) lena原图很有意思,我们通常所用的256*256图片是在lena原图上截取了头部部分的256*256正方形得到的. 原图是花花公子杂志上的一个

【项目实战】 图书信息管理系统(Maven,mybatis)(第一个自己独立完成的项目)

《程序设计综合训练实践报告》 此项目为图书信息管理系统,是一个采用了mysql+mybatis框架+java编写的maven项目

图书管理系统(Java + Mysql)我的第一个完全自己做的实训项目

图书管理系统 Java + MySQL 完整实训代码,MVC三层架构组织,包含所有用到的图片资源以及数据库文件,大三上学期实训,注释很详细,按照阿里巴巴Java编程规范编写

Python入门视频精讲

Python入门视频培训课程以通俗易懂的方式讲解Python核心技术,Python基础,Python入门。适合初学者的教程,让你少走弯路! 课程内容包括:1.Python简介和安装 、2.第一个Python程序、PyCharm的使用 、3.Python基础、4.函数、5.高级特性、6.面向对象、7.模块、8.异常处理和IO操作、9.访问数据库MySQL。教学全程采用笔记+代码案例的形式讲解,通俗易懂!!!

20行代码教你用python给证件照换底色

20行代码教你用python给证件照换底色

2018年全国大学生计算机技能应用大赛决赛 大题

2018年全国大学生计算机技能应用大赛决赛大题,程序填空和程序设计(侵删)

MySQL数据库从入门到实战应用

限时福利1:购课进答疑群专享柳峰(刘运强)老师答疑服务 限时福利2:购课后添加学习助手(微信号:csdn590),按消息提示即可领取编程大礼包! 为什么说每一个程序员都应该学习MySQL? 根据《2019-2020年中国开发者调查报告》显示,超83%的开发者都在使用MySQL数据库。 使用量大同时,掌握MySQL早已是运维、DBA的必备技能,甚至部分IT开发岗位也要求对数据库使用和原理有深入的了解和掌握。 学习编程,你可能会犹豫选择 C++ 还是 Java;入门数据科学,你可能会纠结于选择 Python 还是 R;但无论如何, MySQL 都是 IT 从业人员不可或缺的技能! 【课程设计】 在本课程中,刘运强老师会结合自己十多年来对MySQL的心得体会,通过课程给你分享一条高效的MySQL入门捷径,让学员少走弯路,彻底搞懂MySQL。 本课程包含3大模块:&nbsp; 一、基础篇: 主要以最新的MySQL8.0安装为例帮助学员解决安装与配置MySQL的问题,并对MySQL8.0的新特性做一定介绍,为后续的课程展开做好环境部署。 二、SQL语言篇: 本篇主要讲解SQL语言的四大部分数据查询语言DQL,数据操纵语言DML,数据定义语言DDL,数据控制语言DCL,学会熟练对库表进行增删改查等必备技能。 三、MySQL进阶篇: 本篇可以帮助学员更加高效的管理线上的MySQL数据库;具备MySQL的日常运维能力,语句调优、备份恢复等思路。 &nbsp;

C/C++学习指南全套教程

C/C++学习的全套教程,从基本语法,基本原理,到界面开发、网络开发、Linux开发、安全算法,应用尽用。由毕业于清华大学的业内人士执课,为C/C++编程爱好者的教程。

C/C++跨平台研发从基础到高阶实战系列套餐

一 专题从基础的C语言核心到c++ 和stl完成基础强化; 二 再到数据结构,设计模式完成专业计算机技能强化; 三 通过跨平台网络编程,linux编程,qt界面编程,mfc编程,windows编程,c++与lua联合编程来完成应用强化 四 最后通过基于ffmpeg的音视频播放器,直播推流,屏幕录像,

我以为我对Mysql事务很熟,直到我遇到了阿里面试官

太惨了,面试又被吊打

专为程序员设计的数学课

<p> 限时福利限时福利,<span>15000+程序员的选择!</span> </p> <p> 购课后添加学习助手(微信号:csdn590),按提示消息领取编程大礼包!并获取讲师答疑服务! </p> <p> <br> </p> <p> 套餐中一共包含5门程序员必学的数学课程(共47讲) </p> <p> 课程1:《零基础入门微积分》 </p> <p> 课程2:《数理统计与概率论》 </p> <p> 课程3:《代码学习线性代数》 </p> <p> 课程4:《数据处理的最优化》 </p> <p> 课程5:《马尔可夫随机过程》 </p> <p> <br> </p> <p> 哪些人适合学习这门课程? </p> <p> 1)大学生,平时只学习了数学理论,并未接触如何应用数学解决编程问题; </p> <p> 2)对算法、数据结构掌握程度薄弱的人,数学可以让你更好的理解算法、数据结构原理及应用; </p> <p> 3)看不懂大牛代码设计思想的人,因为所有的程序设计底层逻辑都是数学; </p> <p> 4)想学习新技术,如:人工智能、机器学习、深度学习等,这门课程是你的必修课程; </p> <p> 5)想修炼更好的编程内功,在遇到问题时可以灵活的应用数学思维解决问题。 </p> <p> <br> </p> <p> 在这门「专为程序员设计的数学课」系列课中,我们保证你能收获到这些:<br> <br> <span> </span> </p> <p class="ql-long-24357476"> <span class="ql-author-24357476">①价值300元编程课程大礼包</span> </p> <p class="ql-long-24357476"> <span class="ql-author-24357476">②应用数学优化代码的实操方法</span> </p> <p class="ql-long-24357476"> <span class="ql-author-24357476">③数学理论在编程实战中的应用</span> </p> <p class="ql-long-24357476"> <span class="ql-author-24357476">④程序员必学的5大数学知识</span> </p> <p class="ql-long-24357476"> <span class="ql-author-24357476">⑤人工智能领域必修数学课</span> </p> <p> <br> 备注:此课程只讲程序员所需要的数学,即使你数学基础薄弱,也能听懂,只需要初中的数学知识就足矣。<br> <br> 如何听课? </p> <p> 1、登录CSDN学院 APP 在我的课程中进行学习; </p> <p> 2、登录CSDN学院官网。 </p> <p> <br> </p> <p> 购课后如何领取免费赠送的编程大礼包和加入答疑群? </p> <p> 购课后,添加助教微信:<span> csdn590</span>,按提示领取编程大礼包,或观看付费视频的第一节内容扫码进群答疑交流! </p> <p> <img src="https://img-bss.csdn.net/201912251155398753.jpg" alt=""> </p>

Eclipse archetype-catalog.xml

Eclipse Maven 创建Web 项目报错 Could not resolve archetype org.apache.maven.archetypes:maven-archetype-web

使用TensorFlow+keras快速构建图像分类模型

课程分为两条主线: 1&nbsp;从Tensorflow的基础知识开始,全面介绍Tensorflow和Keras相关内容。通过大量实战,掌握Tensorflow和Keras经常用到的各种建模方式,参数优化方法,自定义参数和模型的手段,以及对训练结果评估与分析的技巧。 2&nbsp;从机器学习基础算法开始,然后进入到图像分类领域,使用MNIST手写数据集和CIFAR10图像数据集,从简单神经网络到深度神经网络,再到卷积神经网络,最终完成复杂模型:残差网络的搭建。完成这条主线,学员将可以自如地使用机器学习的手段来达到图像分类的目的。

Python代码实现飞机大战

文章目录经典飞机大战一.游戏设定二.我方飞机三.敌方飞机四.发射子弹五.发放补给包六.主模块 经典飞机大战 源代码以及素材资料(图片,音频)可从下面的github中下载: 飞机大战源代码以及素材资料github项目地址链接 ————————————————————————————————————————————————————————— 不知道大家有没有打过飞机,喜不喜欢打飞机。当我第一次接触这个东西的时候,我的内心是被震撼到的。第一次接触打飞机的时候作者本人是身心愉悦的,因为周边的朋友都在打飞机, 每

最近面试Java后端开发的感受:如果就以平时项目经验来面试,通过估计很难,不信你来看看

在上周,我密集面试了若干位Java后端的候选人,工作经验在3到5年间。我的标准其实不复杂:第一能干活,第二Java基础要好,第三最好熟悉些分布式框架,我相信其它公司招初级开发时,应该也照着这个标准来面的。 我也知道,不少候选人能力其实不差,但面试时没准备或不会说,这样的人可能在进团队干活后确实能达到期望,但可能就无法通过面试,但面试官总是只根据面试情况来判断。 但现实情况是,大多数人可能面试前没准备,或准备方法不得当。要知道,我们平时干活更偏重于业务,不可能大量接触到算法,数据结构,底层代码这类面试必问

三个项目玩转深度学习(附1G源码)

从事大数据与人工智能开发与实践约十年,钱老师亲自见证了大数据行业的发展与人工智能的从冷到热。事实证明,计算机技术的发展,算力突破,海量数据,机器人技术等,开启了第四次工业革命的序章。深度学习图像分类一直是人工智能的经典任务,是智慧零售、安防、无人驾驶等机器视觉应用领域的核心技术之一,掌握图像分类技术是机器视觉学习的重中之重。针对现有线上学习的特点与实际需求,我们开发了人工智能案例实战系列课程。打造:以项目案例实践为驱动的课程学习方式,覆盖了智能零售,智慧交通等常见领域,通过基础学习、项目案例实践、社群答疑,三维立体的方式,打造最好的学习效果。

微信小程序开发实战之番茄时钟开发

微信小程序番茄时钟视频教程,本课程将带着各位学员开发一个小程序初级实战类项目,针对只看过官方文档而又无从下手的开发者来说,可以作为一个较好的练手项目,对于有小程序开发经验的开发者而言,可以更好加深对小程序各类组件和API 的理解,为更深层次高难度的项目做铺垫。

相关热词 c#分级显示数据 c# 不区分大小写替换 c#中调用就java c#正则表达式 验证小数 c# vscode 配置 c#三维数组能存多少数据 c# 新建excel c#多个文本框 c#怎么创建tcp通讯 c# mvc 电子病例
立即提问