Android 中写了一个listview,运行就闪退

一个MainActivity中有三个Fragment(其中有个为MovieFrament),下面这个ViewingFragment是MovieFragment中的一个嵌套的Fragment

package com.example.movie;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterViewFlipper;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;

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

/**

  • A simple {@link Fragment} subclass.
    */
    public class ViewingFragment extends Fragment {
    private ListView listView;
    private List movieList;
    private List> data = new ArrayList>();
    public ViewingFragment() {
    // Required empty public constructor
    }
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
    Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_viewing,container,false);
    listView = (ListView) view.findViewById(R.id.mov_listview);
    movieList=initmovies(movieList);
    for (int i = 0; i < movieList.size(); i++) {
    HashMap map = new HashMap();
    map.put("name", movieList.get(i).getName());
    map.put("imageId", movieList.get(i).getImageId());
    map.put("director", movieList.get(i).getDirector());
    map.put("charactors", movieList.get(i).getCharactors());
    data.add(map);
    }
    SimpleAdapter adapter = new SimpleAdapter(getParentFragment().getActivity(), data, R.layout.movie2_item,
    new String[]{ "name", "imageId", "director" ,"charactors"}, new int[]{ R.id.txt_name,
    R.id.imageId,
    R.id.txt_director,
    R.id.txt_charactors});
    listView.setAdapter(adapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener(){
    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    //我们需要的内容,跳转页面或显示详细信息
    Intent intent=new Intent(getActivity(),Mov_InfActivity.class);
    startActivity(intent);
    }
    });

    return view;
    

    }
    private static List initmovies(List movieList) {

    Movie2 apple = new Movie2("悲伤逆流成河", R.mipmap.beishang,"导演:落落","主演:赵英博 任敏 辛云来");
    movieList.add(apple);
    Movie2 banana = new Movie2("新灰姑娘", R.mipmap.huigul,"导演:琳恩.萨瑟兰","主演:Kristen");
    movieList.add(banana);
    Movie2 orange = new Movie2("李茶的姑妈", R.mipmap.licha,"导演:吴昱翰","主演:黄才伦 艾伦 宋阳");
    movieList.add(orange);
    Movie2 watermelon = new Movie2("胖子行动队", R.mipmap.pangzi,"导演:包贝尔 秦小珍","主演:包贝尔 文章 克拉拉");
    movieList.add(watermelon);
    Movie2 pear = new Movie2("无双", R.mipmap.wushuang,"导演:庄文强","主演:周润发 郭富城 张静初");
    movieList.add(pear);
    Movie2 grape = new Movie2("嘻哈英熊", R.mipmap.xiha,"导演:王琦","主演:林强 刘康 徐梦娟");
    movieList.add(grape);
    Movie2 pineapple = new Movie2("影", R.mipmap.ying,"导演:张艺谋","主演:邓超 孙俪 郑恺");
    movieList.add(pineapple);
    Movie2 strawberry = new Movie2("找到你", R.mipmap.zhaodaoni,"导演:吕乐","主演:姚晨 马伊俐 袁文康");
    movieList.add(strawberry);
      return movieList;
    

    }
    }

2个回答

movieList没有初始化;
你自己在initmovies(List movieList)打断点看一下,movieList是null吧?

zengruiyue
QianXingZ 回复weixin_36767032:如楼下说的,这问题要学会自己解决, 要学会调试,看错误报告;不过有一点就是非常资深的有时也会放这种低级错误的
大约一年之前 回复
weixin_36767032
weixin_36767032 谢谢
大约一年之前 回复

不能什么都提问,要自己解决,这个是最基础的错误了
新手帖先看一下吧,有疑问的可以在里面提问https://blog.csdn.net/weimingjue/article/details/87921494

weixin_36767032
weixin_36767032 知道了,谢谢
大约一年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
一点击ListView就闪退

一点击ListVIew就闪退,调试了两天了,好痛苦,望大家解救。 **这是部分日志** *02-06 10:58:39.207: E/InputEventReceiver(764): Exception dispatching input event. 02-06 10:58:39.207: E/MessageQueue-JNI(764): Exception in MessageQueue callback: handleReceiveCallback 02-06 10:58:39.377: E/MessageQueue-JNI(764): java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread. [in ListView(16908298, class android.widget.ListView) with Adapter(class android.widget.SimpleAdapter)] 02-06 10:58:39.377: E/MessageQueue-JNI(764): at android.widget.ListView.layoutChildren(ListView.java:1538) * 部分代码: * protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_clear); bar = (ProgressBar) findViewById(R.id.progressBar0); list = new ArrayList<HashMap<String, String>>(); SimpleAdapter adapter = new SimpleAdapter(this, list, R.layout.list_view, new String[] { "name", "size", "path"}, new int[] { R.id.name, R.id.size, R.id.path }); setListAdapter(adapter); System.out.println("hh"); handler = new MyHandler(); thread = new MyThread(); thread.start(); } private void SendMessage(String name, String path, String size) { Message message = handler.obtainMessage(); HashMap<String, String> hashMap = new HashMap<String, String>(); hashMap.put("name", name); hashMap.put("path", path); hashMap.put("size", size); message.obj = hashMap; handler.sendMessage(message); } class MyHandler extends Handler { @Override public void handleMessage(Message msg) { HashMap<String, String> hashMap = (HashMap<String, String>) msg.obj; list.add(hashMap); } } *

写了个ListView,打开就崩溃

用的Android Studio。Activity自动在manifests里注册了。 将该activity设置为打开加载页面时,打开就直接闪退。 错误信息一闪就没了... Java代码: package com.demo.listview; import android.app.Activity; import android.os.Bundle; import android.widget.ArrayAdapter; import android.widget.ListView; public class MyLIST extends Activity { private String[] list=getResources().getStringArray(R.array.lesson_name_list_cn); private ListView lv; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_list); lv=(ListView)findViewById(R.id.lv); lv.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1,list)); } } XML: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" tools:context="com.demo.listview"> <!--添加一个ListView控件--> <ListView android:id="@+id/lv" android:layout_width="match_parent" android:layout_height="match_parent"> </ListView> </LinearLayout>

android listview setAdapter()方法导致闪退

代码如下,想要实现点击一个checkBox之后,弹出一个dialog,其中用listview来显示带有图标和应用信息的列表,但是运行之后会闪退,提示 listview.setAdapter(browseAppAdapter); 这行代码空指针错误,求解 ``` checkBox.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub if (checkBox.isChecked()) { final Dialog dialog = new Dialog(getActivity()); dialog.setContentView(R.layout.browse_app_list); dialog.setTitle("应用列表"); mlistAppInfo = new ArrayList<AppInfo>(); queryAppInfo(); // 查询所有应用程序信息 BrowseApplicationInfoAdapter browseAppAdapter = new BrowseApplicationInfoAdapter( getActivity(), mlistAppInfo); listview.setAdapter(browseAppAdapter); listview.setOnItemClickListener(new OnItemClickListener(){ @Override public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) { // TODO Auto-generated method stub intent = mlistAppInfo.get(position).getIntent(); } }); dialog.show(); } } }); ```

Fragment使用嵌套listview闪退

import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ListView; public class babyFragment extends Fragment { ListView lv_main;//页面整体list显示 babyViewPagerAdapter babyFramentAdapter; //启动页面 @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.a, null); FragmentManager fm = getActivity().getSupportFragmentManager(); babyFramentAdapter = new babyViewPagerAdapter(getActivity(), fm); lv_main = (ListView) v.findViewById(R.id.listview); lv_main.setAdapter(babyFramentAdapter); return v; } } import android.content.*; import android.support.v4.app.*; import android.view.*; import android.widget.*; import kabu.love.zwy.*; public class babyViewPagerAdapter extends BaseAdapter { FragmentManager fm; public babyViewPagerAdapter(Context pContext, FragmentManager fm_tmp) { this.mContext = pContext; fm = fm_tmp; } Context mContext; @Override public int getCount() { return 2; } @Override public Object getItem(int i) { return null; } @Override public long getItemId(int i) { return i; } @Override public View getView(int i, View view, ViewGroup viewGroup) { LayoutInflater _LayoutInflater = LayoutInflater.from(mContext); switch (i) { case 0: view = _LayoutInflater.inflate( R.layout.mc, viewGroup, false); babyFragment mOneFrament = new babyFragment(); FragmentTransaction babyInfotransaction = fm.beginTransaction(); babyInfotransaction.add(R.id.listview, mOneFrament).commit(); TextView k=(TextView) view.findViewById(R.id.kabu); k.append("k"); break; case 1: view = _LayoutInflater.inflate( R.layout.mc, viewGroup, false); babyFragment mTwoFrament = new babyFragment(); FragmentTransaction feedArchivestransaction = fm.beginTransaction(); feedArchivestransaction.add(R.id.listview, mTwoFrament).commit(); TextView y=(TextView) view.findViewById(R.id.kabu); y.append("y"); break; case 2:// break; case 3:// break; case 4:// break; case 5:// break; } return view; } } 谁帮忙解决一下,打开程序停留1秒闪退,

android加了button 运行会闪退

加了BUTTON后 哪怕不加监听事件他都闪退 去掉BUTTON就正常 为什么呀 ``` /** * */ package com.nav.gamepack; import com.nav.gamepack.puzzle.jigsaw.JigsawBoardView; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; /** * @author Administrator * */ public class welcomeclass extends Activity { public Button trans =(Button)findViewById(R.id.button1); @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.start); //trans.setOnClickListener(new OnClickListener(){} ); trans.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //startActivity(new Intent("GamePackActivity")); } }); } ```

自学Android开发 在模拟器运行闪退

初学者自写的程序 ,但是在模拟器下运行闪退!!该怎么改呀?? package com.example.work3; import java.util.ArrayList; import java.util.List; import android.support.v7.app.ActionBarActivity; import android.support.v7.app.ActionBar; import android.support.v4.app.Fragment; import android.annotation.SuppressLint; import android.app.AlertDialog; import android.app.TabActivity; import android.content.DialogInterface; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.StrictMode; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.ListView; import android.widget.Spinner; import android.widget.TabHost; import android.widget.TextView; import android.os.Build; public class MainActivity extends TabActivity { private TabHost tabhost; private ListView listview; private ArrayAdapter<String> arr_adapter; private Spinner spinner; private List<String>list; private ArrayAdapter<String> adapter; private EditText et1,et2; private Button bt; String name; String value; String style; @SuppressLint("NewApi") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); et1=(EditText) findViewById(R.id.editText1); et2=(EditText) findViewById(R.id.editText2); bt=(Button) findViewById(R.id.button1); setContentView(R.layout.activity_main); tabhost=getTabHost(); tabhost.addTab(tabhost.newTabSpec("菜单一").setIndicator("首页").setContent(R.id.tab1)); tabhost.addTab(tabhost.newTabSpec("菜单二").setIndicator("新增").setContent(R.id.tab2)); tabhost.addTab(tabhost.newTabSpec("菜单三").setIndicator("账单").setContent(R.id.tab3)); //按钮监听 提取信息 bt.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub name = et1.getText().toString(); value = et2.getText().toString(); style = spinner.getSelectedItem().toString(); } }); listview = (ListView) findViewById(R.id.listview); //新建适配器 String[]arr_data={"数据1","数据2","数据3","数据4","数据5"}; //ArrayAdapter(上下文,当前ListView加载的每一个列表项所对应的布局文件,数据源) arr_adapter =new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,arr_data); listview.setAdapter(arr_adapter); spinner=(Spinner) findViewById(R.id.spinner); //数据源 String[]list = {"1.日常食品支出","2.人情世故支出","3.出差旅游支出","4.服饰鞋帽支出","5.生活用品支出","6.其他支出"}; //新建适配器 adapter=new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, list); //设置下拉样式 adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); //加载适配器 spinner.setAdapter(adapter); } //退出对话框 @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK ) { // 创建退出对话框 AlertDialog isExit = new AlertDialog.Builder(this).create(); // 设置对话框标题 isExit.setTitle("系统提示"); // 设置对话框消息 isExit.setMessage("确定要退出吗"); // 添加选择按钮并注册监听 isExit.setButton("确定", listener); isExit.setButton2("取消", listener); // 显示对话框 isExit.show(); } return false; } /**监听对话框里面的button点击事件*/ DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { switch (which) { case AlertDialog.BUTTON_POSITIVE:// "确认"按钮退出程序 finish(); break; case AlertDialog.BUTTON_NEGATIVE:// "取消"第二个按钮取消对话框 break; default: break; } } }; }

使用Android studio编写的程序,写好代码后运行app到模拟器的时候会闪退

希望懂的大佬能帮帮忙,救救我,这个问题困扰我好久了,这个问题没解决就无法进行下一步。 1.最近使用Android studio编写了一个程序,写好代码后运行app到模拟器的时候会闪退(创建时程序版本和模拟器版本相同为5.1)。没有写代码时(也就是刚创建好程序,没添加任何东西时),在模拟器中能正常运行,但是当我写好代码后,运行app到模拟器上就会闪退了。 2.在代码部分,我是根据的SuperMap iMobile 9D(2019) for Android Guide的指导书写的,现在我也配置了许可,但还是会闪退 3.各个部分的代码如下: ``` <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.loadscence"> <uses-permission android:name="android.permission.INTERNET"></uses-permission> <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"></uses-permission> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission> <uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission> <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"></uses-permission> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".MainActivity" android:label="@string/app_name" android:configChanges="keyboardHidden|orientation|screenSize" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> <supports-screens android:largeScreens="true" android:resizeable="true" android:normalScreens="true" android:anyDensity="true"/> </manifest> ///////////////////////////////////////////////////////////这是mainactivity.java的代码 package com.example.loadscence; import androidx.appcompat.app.AppCompatActivity; import android.view.Menu; import android.view.MenuItem; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.ZoomControls; import com.supermap.data.Environment; import com.supermap.data.Workspace; import com.supermap.data.WorkspaceConnectionInfo; import com.supermap.data.WorkspaceType; import com.supermap.mapping.MapControl; import com.supermap.mapping.MapView; public class MainActivity extends AppCompatActivity { private MapControl m_mapcontrol = null; private Workspace m_workspace; private MapView m_mapView; private ZoomControls m_zoom; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //设置一些系统需要用到的路径 String rootPath = android.os.Environment.getExternalStorageDirectory().getAbsolutePath(); Environment. setLicensePath (rootPath + "/SuperMap/license/"); Environment. setTemporaryPath (rootPath + "/SuperMap/temp/"); Environment. setWebCacheDirectory (rootPath + "/SuperMap/WebCatch"); //组件功能必须在 Environment 初始化之后才能调用 Environment. initialization (this); //如果机器中默认不包括需要显示的字体,可以把相关字体文件放在参数所代表的路径中。 //例如,如果需要显示阿拉伯文字(若机器中原先不包括相关字体文件),可以把需要的字体文件放在参数所代表的路径中。 Environment. setFontsPath (rootPath + "/SuperMap/fonts/"); setContentView(R.layout. activity_main ); //打开工作空间 m_workspace = new Workspace(); WorkspaceConnectionInfo info = new WorkspaceConnectionInfo(); info.setServer(rootPath + "/SampleData/GeometryInfo/World.smwu"); info.setType(WorkspaceType. SMWU ); m_workspace.open(info); //将地图显示控件和工作空间关联 m_mapView = (MapView)findViewById(R.id. Map_view ); m_mapcontrol = m_mapView.getMapControl(); m_mapcontrol.getMap().setWorkspace(m_workspace); //打开工作空间中的第二幅地图 String mapName = m_workspace.getMaps().get(1); m_mapcontrol.getMap().open(mapName); m_zoom = (ZoomControls)findViewById(R.id. zoomControls1 ); m_mapView = (MapView)findViewById(R.id. Map_view ); m_zoom.setIsZoomInEnabled(true); m_zoom.setIsZoomOutEnabled(true); //放大按钮 m_zoom.setOnZoomInClickListener(new OnClickListener() { public void onClick(View v) { m_mapcontrol.getMap().zoom(2); m_mapcontrol.getMap().refresh(); } }); //缩小按钮 m_zoom.setOnZoomOutClickListener(new OnClickListener(){ public void onClick(View v) { m_mapcontrol.getMap().zoom(0.5); m_mapcontrol.getMap().refresh(); } }); m_mapcontrol.getMap().refresh(); } } ///////////////////////////////////////////////////////////这是activity的代码 <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/main"> <RelativeLayout android:gravity="left" android:layout_width="match_parent" android:layout_height="match_parent"> <com.supermap.mapping.MapView android:id = "@+id/Map_view" android:layout_width="match_parent" android:layout_height = "match_parent"> </com.supermap.mapping.MapView> <ZoomControls android:id="@+id/zoomControls1" android:layout_alignParentBottom="true" android:layout_alignParentRight="true" android:layout_centerHorizontal="true" android:layout_width="wrap_content" android:layout_height="wrap_content"> </ZoomControls> </RelativeLayout> </RelativeLayout> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World!" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" /> </androidx.constraintlayout.widget.ConstraintLayout> ///////////////////////////////////////////////////////////报错日志如下: 03-23 22:32:10.438 22856-22856/com.example.loadscence E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.loadscence, PID: 22856 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.loadscence/com.example.loadscence.MainActivity}: java.lang.NullPointerException: Attempt to get length of null array at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) at android.app.ActivityThread.access$800(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5254) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) Caused by: java.lang.NullPointerException: Attempt to get length of null array at com.supermap.data.Environment.checkAndLoadLibrary64(Environment.java:1632) at com.supermap.data.Environment.initialization(Environment.java:576) at com.example.loadscence.MainActivity.onCreate(MainActivity.java:33) at android.app.Activity.performCreate(Activity.java:5990) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)  at android.app.ActivityThread.access$800(ActivityThread.java:151)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:135)  at android.app.ActivityThread.main(ActivityThread.java:5254)  at java.lang.reflect.Method.invoke(Native Method)  at java.lang.reflect.Method.invoke(Method.java:372)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)  ```

在fragment中的listView问题

在fragment中显示一个自定义listView,但是运行后什么也没显示。 public class Tab1 extends Fragment implements ListView.OnItemClickListener{ private ArrayList<Custom> fetch = new ArrayList<Custom>(); private ContactsAdapter adapter; private ListView lv; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle saveInstanceState){ View v = inflater.inflate(R.layout.tab_layout, container, false); Custom one = new Custom("Hoang Ha", "01672286349"); Custom two = new Custom("Ha Link", "03203590176"); fetch.add(one); fetch.add(two); lv =(ListView)v.findViewById(R.id.list); adapter = new ContactsAdapter(getActivity(), fetch); lv.setAdapter(adapter); lv.setOnItemClickListener(this); return v; } public class Custom{ private String contactName; private String contactPhone; public Custom(String st1, String st2){ contactName = st1; contactPhone = st2; } public String getName(){ return contactName; } public String getPhone(){ return contactPhone; } public void setName(String st1){ contactName = st1; } public void setPhone(String st2){ contactPhone = st2; } } @Override public void onItemClick(AdapterView<?> ad, View v, int position, long id) { // TODO Auto-generated method stub } private class ContactsAdapter extends BaseAdapter{ private FragmentActivity activity; private LayoutInflater inflater; private ArrayList<Custom> data; public ContactsAdapter (FragmentActivity a, ArrayList<Custom> d){ activity = a; data = d; inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } @Override public int getCount() { // TODO Auto-generated method stub data.size(); return 0; } @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 View v = convertView; v = inflater.inflate(R.layout.list_row, null); TextView contact_name = (TextView)v.findViewById(R.id.contact_name); TextView phone_number = (TextView)v.findViewById(R.id.phone_number); //final Custom custom = entries.get(position); final Custom custom = data.get(position); contact_name.setText(custom.getName()); phone_number.setText(custom.getPhone()); return v; } } } 这是列表xml代码: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:background="@color/light_dark" android:padding="5dip" > <TextView android:id="@+id/contact_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/name" android:textColor="@color/white" android:typeface="sans" android:textSize="@dimen/font_medium" android:textStyle="bold"/> <TextView android:id="@+id/phone_number" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/name" android:textColor="@color/white" android:typeface="sans" android:textSize="@dimen/font_small" /> </LinearLayout>

没有activity点按钮闪退

初步写android程序 写登录界面 的按钮添加了一句click属性 activity还没有写 运行程序点按钮闪退 去掉这句话就不会 为什么 求解释 新人 并不能看懂logcat![图片说明](https://img-ask.csdn.net/upload/201608/07/1470555430_604207.png)![图片说明](https://img-ask.csdn.net/upload/201608/07/1470555340_663486.png)

android fragment中listview.setAdapter为空的问题

android新手想多联系下fragment的使用,可在listview.setAdapter时遇到了如下问题: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference at com.example.sms.InsertFragment.onCreate(InsertFragment.java:73) 以下是代码 ``` private ListView insert_choose_listView; ArrayList<HashMap<String, String>> listItem; MyAdapter myAdapter; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getArguments() != null) { mParam1 = getArguments().getString(ARG_PARAM1); mParam2 = getArguments().getString(ARG_PARAM2); } listItem = new ArrayList<HashMap<String,String>>(); HashMap<String, String> map = new HashMap<String, String>(); map.put("Insert"," Insert Teacher");listItem.add(map); map.put("Insert"," Insert Student");listItem.add(map); map.put("Insert"," Insert Course");listItem.add(map); myAdapter=new MyAdapter(this.getActivity()); insert_choose_listView.setAdapter(myAdapter); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View view=inflater.inflate(R.layout.fragment_insert, container, false); insert_choose_listView=(ListView)view.findViewById(R.id.insert_choose_listview); return view; } private class MyAdapter extends BaseAdapter { private LayoutInflater mInflater;//得到一个LayoutInfalter对象用来导入布局 public MyAdapter (Context context){ this.mInflater= LayoutInflater.from(context); } public int getCount(){ return listItem.size(); } @Override public Object getItem(int position) { return null; } @Override public long getItemId(int position) { return 0; } @Override public View getView(final int position, View convertView, ViewGroup parent) { InsertFragment.MyAdapter.ViewHolder holder; //观察convertView随ListView滚动情况 Log.v("MyListViewBase", "getView " + position + " " + convertView); if (convertView == null) { convertView = mInflater.inflate(R.layout.flistviewlayout,null); holder = new InsertFragment.MyAdapter.ViewHolder(); /**得到各个控件的对象*/ holder.title = (TextView) convertView.findViewById(R.id.ftext); convertView.setTag(holder);//绑定ViewHolder对象 } else{ holder = (InsertFragment.MyAdapter.ViewHolder)convertView.getTag();//取出ViewHolder对象 } /**设置TextView显示的内容,即我们存放在动态数组中的数据*/ holder.title.setText(listItem.get(position).get("Insert").toString()); return convertView; } /**存放控件*/ public final class ViewHolder{ public TextView title; } ``` 报错的73行是insert_choose_listView.setAdapter(myAdapter);这句 我在Activity中这样加入ListView是不会报错的可是放到Fragment中就成了空的 求解答

Android socket通讯客户端连不上服务器问题,以及发送消息程序就闪退

原本以为是线程问题但是好像又不是,实在找不到怎么弄了 这是客户端: package com.chiaki.mysocketobject; import android.content.Intent; import android.os.Handler; import android.os.Message; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.EditText; import android.widget.ImageButton; import android.widget.ListView; import android.widget.TextView; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.net.Socket; import java.util.ArrayList; import java.util.List; public class ChatActivity extends AppCompatActivity implements Runnable{ private static final String HOST = "172.16.2.54"; private static final int PORT = 12345; private MsgAdapter adapter; private ListView msgListView; private List<Msg> msgList=new ArrayList<Msg>(); private ImageButton send; private ImageButton connect; private EditText edit; private TextView ctext; private Socket socket; private BufferedReader in = null; private PrintWriter out = null; private String content = ""; private StringBuilder sb = null; public Handler handler = new Handler() { public void handleMessage(Message msg) { if (msg.what == 0x123) { sb.append(content); ctext.setText(sb.toString()); } } }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_chat); adapter=new MsgAdapter(ChatActivity.this,R.layout.chat_list_view,msgList); ImageButton back = (ImageButton)findViewById(R.id.back); ImageButton voiceButton = (ImageButton)findViewById(R.id.voiceButton); connect = (ImageButton)findViewById(R.id.connectButton); send = (ImageButton)findViewById(R.id.send); edit = (EditText)findViewById(R.id.edit); ctext = (TextView)findViewById(R.id.chattext); msgListView=(ListView)findViewById(R.id.msg_list_view); sb = new StringBuilder(); msgListView.setAdapter(adapter); // 点击按钮实例化Socket对象,与服务端进行连接,获取输入输出流 // 连接服务器,要在子线程中 connect.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new Thread() { @Override public void run() { super.run(); try { // 创建socket,连接服务器 socket = new Socket(HOST, PORT);//连接服务器 in = new BufferedReader(new InputStreamReader(socket.getInputStream(), "UTF-8"));//接收消息的流对象 out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())), true);//发送消息的流对象 } catch (Exception e) { e.printStackTrace(); } } }.start(); } }); back.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(ChatActivity.this,SocketActivity.class); startActivity(intent); } }); send.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String con=edit.getText().toString(); edit.setText(""); if (socket.isConnected()) { if (!socket.isOutputShutdown()) { out.println(con);//点击按钮发送消息 } } } }); //启动线程,连接服务器,并用死循环守候,接收服务器发送过来的数据 new Thread(ChatActivity.this).start(); } // 重写run方法,在该方法中输入流的读取 public void run() { try { while (true) { //死循环守护,监控服务器发来的消息 if (socket.isConnected()) { //如果服务器没有关闭 if (!socket.isInputShutdown()) { //连接正常 if ((content = in.readLine()) != null) { //如果输入流没有断开 content += "\n"; //读取接收的信息 handler.sendEmptyMessage(0x123); //会发送一个空消息,但是指定了Message的what属性 } } } } } catch (Exception e) { e.printStackTrace(); } } } 这是layout文件主要的控件: <ImageButton //建立连接按钮 android:layout_width="wrap_content" android:layout_height="wrap_content" app:srcCompat="@android:drawable/checkbox_on_background" android:id="@+id/connectButton" android:layout_alignParentStart="true" android:layout_below="@+id/edit" /> <TextView //显示消息 android:text="TextView" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/chattext" /> <ImageButton //编辑消息 android:layout_width="wrap_content" android:layout_height="wrap_content" app:srcCompat="@android:drawable/ic_btn_speak_now" android:id="@+id/voiceButton" android:layout_below="@+id/edit" android:layout_centerHorizontal="true" /> <ImageButton //发送消息 android:layout_width="wrap_content" android:layout_height="40dp" app:srcCompat="@android:drawable/ic_menu_send" android:id="@+id/send" android:backgroundTint="?attr/colorButtonNormal" android:layout_alignParentBottom="true" android:layout_alignParentEnd="true" /> 这是服务端: import java.io.DataInputStream; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.net.ServerSocket; import java.net.Socket; import java.util.ArrayList; import java.util.List; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.io.IOException; import java.net.ServerSocket; import java.net.Socket; public class Server { // 定义相关的参数,端口,存储Socket连接的集合,ServerSocket对象 // 以及线程池 private static final int PORT = 12345; private List<Socket> mList = new ArrayList<Socket>(); private ServerSocket server = null; private ExecutorService myExecutorService = null; public static void main(String[] args) { new Server(); } public Server() { try { server = new ServerSocket(PORT); // 创建线程池 myExecutorService = Executors.newCachedThreadPool(); System.out.println("服务端运行中...\n"); Socket client = null; while (true) { client = server.accept(); mList.add(client); myExecutorService.execute(new Service(client)); } } catch (Exception e) { e.printStackTrace(); } } class Service implements Runnable { private Socket socket; private BufferedReader in = null; private String msg = ""; public Service(Socket socket) { this.socket = socket; try { in = new BufferedReader(new InputStreamReader(socket.getInputStream())); System.out.println("用户:" + this.socket.getInetAddress() + "~加入了聊天室" + "当前在线人数:" + mList.size()); } catch (IOException e) { e.printStackTrace(); } } @Override public void run() { try { while (true) { if ((msg = in.readLine()) != null) { if (msg.equals("bye")) { System.out.println("~~~~~~~~~~~~~"); mList.remove(socket); in.close(); System.out.println("用户:" + socket.getInetAddress() + "退出:" + "当前在线人数:" + mList.size()); socket.close(); break; } else { System.out.println(socket.getInetAddress() + " 说: " + msg); this.sendmsg(); } } } } catch (Exception e) { e.printStackTrace(); } } // 为连接上服务端的每个客户端发送信息 public void sendmsg() { int num = mList.size(); for (int index = 0; index < num; index++) { Socket mSocket = mList.get(index); PrintWriter pout = null; try { pout = new PrintWriter( new BufferedWriter(new OutputStreamWriter(mSocket.getOutputStream(), "UTF-8")), true); pout.println(msg); } catch (IOException e) { e.printStackTrace(); } } } } }

关于Android程序闪退的错误日志

编写了一个包含listview的页面,listview基于另外一个activity可以通过按钮进行操作 但是在打开程序时出现了闪退现象,求大神帮忙解读一下错误日志,感谢 04-13 23:39:21.103: D/ResourcesManager(18150): For user 0 new overlays fetched Null 04-13 23:39:21.113: W/System(18150): ClassLoader referenced unknown path: /data/app/com.example.newrecorder-1/lib/arm64 04-13 23:39:21.173: D/AbsListView(18150): Get MotionRecognitionManager 04-13 23:39:21.183: E/MotionRecognitionManager(18150): mSContextService = android.hardware.scontext.ISContextService$Stub$Proxy@23c9d5e 04-13 23:39:21.183: E/MotionRecognitionManager(18150): motionService = com.samsung.android.motion.IMotionRecognitionService$Stub$Proxy@75d53f 04-13 23:39:21.183: E/MotionRecognitionManager(18150): motionService = com.samsung.android.motion.IMotionRecognitionService$Stub$Proxy@75d53f 04-13 23:39:21.183: I/MediaPlayer(18150): Need to enable context aware info 04-13 23:39:21.183: V/MediaPlayer-JNI(18150): native_setup 04-13 23:39:21.193: E/ExtMediaPlayer-JNI(18150): env->IsInstanceOf fails 04-13 23:39:21.193: E/MediaPlayer-JNI(18150): JNIMediaPlayerFactory: bIsQCMediaPlayerPresent 0 04-13 23:39:21.193: E/ExtMediaPlayer-JNI(18150): env->IsInstanceOf fails 04-13 23:39:21.193: E/MediaPlayer-JNI(18150): JNIMediaPlayerFactory: bIsQCMediaPlayerPresent 0 04-13 23:39:21.193: V/MediaPlayer(18150): constructor 04-13 23:39:21.193: V/MediaPlayer(18150): setListener 04-13 23:39:21.193: D/AndroidRuntime(18150): Shutting down VM 04-13 23:39:21.193: E/AndroidRuntime(18150): FATAL EXCEPTION: main 04-13 23:39:21.193: E/AndroidRuntime(18150): Process: com.example.newrecorder, PID: 18150 04-13 23:39:21.193: E/AndroidRuntime(18150): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.newrecorder/com.example.newrecorder.MainActivity}: java.lang.RuntimeException: setAudioSource failed. 04-13 23:39:21.193: E/AndroidRuntime(18150): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3254) 04-13 23:39:21.193: E/AndroidRuntime(18150): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3350) 04-13 23:39:21.193: E/AndroidRuntime(18150): at android.app.ActivityThread.access$1100(ActivityThread.java:223) 04-13 23:39:21.193: E/AndroidRuntime(18150): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) 04-13 23:39:21.193: E/AndroidRuntime(18150): at android.os.Handler.dispatchMessage(Handler.java:102) 04-13 23:39:21.193: E/AndroidRuntime(18150): at android.os.Looper.loop(Looper.java:148) 04-13 23:39:21.193: E/AndroidRuntime(18150): at android.app.ActivityThread.main(ActivityThread.java:7224) 04-13 23:39:21.193: E/AndroidRuntime(18150): at java.lang.reflect.Method.invoke(Native Method) 04-13 23:39:21.193: E/AndroidRuntime(18150): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 04-13 23:39:21.193: E/AndroidRuntime(18150): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 04-13 23:39:21.193: E/AndroidRuntime(18150): Caused by: java.lang.RuntimeException: setAudioSource failed. 04-13 23:39:21.193: E/AndroidRuntime(18150): at android.media.MediaRecorder._setAudioSource(Native Method) 04-13 23:39:21.193: E/AndroidRuntime(18150): at android.media.MediaRecorder.setAudioSource(MediaRecorder.java:488) 04-13 23:39:21.193: E/AndroidRuntime(18150): at com.example.newrecorder.MainActivity.onCreate(MainActivity.java:57) 04-13 23:39:21.193: E/AndroidRuntime(18150): at android.app.Activity.performCreate(Activity.java:6877) 04-13 23:39:21.193: E/AndroidRuntime(18150): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1136) 04-13 23:39:21.193: E/AndroidRuntime(18150): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3207) 04-13 23:39:21.193: E/AndroidRuntime(18150): ... 9 more 04-13 23:39:23.273: I/Process(18150): Sending signal. PID: 18150 SIG: 9

修改xml文件后,app就闪退了

我修改了layou下的xml文件,然后app就闪退了。 代码添加了“”android:id="@+id/order_sales_percentage_layout"“” <RelativeLayout android:id="@+id/order_sales_percentage_layout" style="@style/activity_content_table_relativelayout_attrs" android:layout_height="wrap_content" > <TextView android:id="@+id/order_sales_percentage_textv" style="@style/activity_content_table_row_title_attrs" android:text="@string/order_sales_percentage" /> </RelativeLayout> log: D/NativeCrypto(9949): ssl=0xee46e000 info_callback ignored D/NativeCrypto(9949): doing handshake -- ret=1 D/NativeCrypto(9949): ssl=0xee46e000 NativeCrypto_SSL_get_certificate => NULL I/System.out(9949): gba_cipher_suite:TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 I/System.out(9949): >doSendRequest D/NativeCrypto(9949): ssl=0xee46e000 sslWrite buf=0xee5d3000 len=389 write_timeout_millis=0 D/NativeCrypto(9949): ssl=0xee46e000 sslWrite buf=0xee486200 len=380 write_timeout_millis=0 I/System.out(9949): <doSendRequest D/NativeCrypto(9949): ssl=0xee46e000 sslRead buf=0xee5d3000 len=8192,timeo=10000 D/UsbDeviceManager(918): onReceive - BATTERY_CHANGED - mPlugType: 2, mSettingUsbCharging: false, mConnected: true, mSettingUsbBicr: false D/WifiService(918): onReceive, action:android.intent.action.BATTERY_CHANGED D/PSD(377): Prox is far ps 206 als 229 highlight 0 crosstalk 205 D/OpenGLRenderer(9949): Flushing caches (mode 0) D/Surface(9949): Surface::disconnect(this=0xf49cc400,api=1) D/OpenGLRenderer(9949): Flushing caches (mode 0) V/WindowManager(918): Changing focus from Window{1b3780a2 u0 cn.com.antika.business/com.GlamourPromise.Beauty.Business.LoginActivity EXITING} to Window{3eae745 u0 cn.com.antika.business/com.GlamourPromise.Beauty.Business.LoginActivity} Callers=com.android.server.wm.WindowManagerService.removeWindowLocked:3238 com.android.server.wm.WindowManagerService.removeWindow:3174 com.android.server.wm.Session.remove:193 android.view.IWindowSession$Stub.onTransact:233 I/WindowManager(918): Gaining focus: Window{3eae745 u0 cn.com.antika.business/com.GlamourPromise.Beauty.Business.LoginActivity} I/WindowManager(918): Losing focus: Window{1b3780a2 u0 cn.com.antika.business/com.GlamourPromise.Beauty.Business.LoginActivity EXITING} I/ActivityManager(918): START u0 {cmp=cn.com.xxxx.business/com.xxx.xxx.Business.CompanySelectActivity (has extras)} from uid 10126 from pid 9949 on display 0 I/SafeCenter.AppProtectService(27567): activityStarting() intent: Intent { cmp=cn.com.antika.business/com.GlamourPromise.Beauty.Business.CompanySelectActivity (has extras) } V/WindowManager(918): addAppToken: AppWindowToken{3d016c25 token=Token{290a481c ActivityRecord{1f3cd8f u0 cn.com.antika.business/com.GlamourPromise.Beauty.Business.CompanySelectActivity t130}}} to stack=1 task=130 at 1 I/libPerfService(918): 1: set freq: 1001000, 1508000 I/libPerfService(918): 1: set: 4, 4 I/libPerfService(918): 1: set vcore level: 3 0V/InputMethodManager(9949): onWindowFocus: android.widget.EditText{1a4a3e58 VFED..C. .F...... 70,380-650,462 #7f0a0330 app:id/login_password_edit_text} softInputMode=32 first=false flags=#1810100 V/InputMethodManagerService(918): windowGainedFocus: android.os.BinderProxy@46afcb7 controlFlags=#3 softInputMode=#20 windowFlags=#1810100 W/InputMethodManagerService(918): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@322c81fa attribute=null, token = android.os.BinderProxy@314e3bbc I/PPS(918): [PPSNotifyAppState] nPackNum:1, pack:cn.com.antika.business, com:com.GlamourPromise.Beauty.Business.CompanySelectActivity, state:1, pid:0, last_boost_tid:-1 D/ActivityManager(918): Delay resumeKeyDispatchingLocked() to avoid deadlock. I/PPS(918): [PPSNotifyAppState] nPackNum:1, pack:cn.com.antika.business, com:com.GlamourPromise.Beauty.Business.LoginActivity, state:0, pid:0, last_boost_tid:-1 D/AbsListView(9949): checkAbsListViewlLogProperty get invalid command V/PhoneWindow(9949): DecorView setVisiblity: visibility = 4 ,Parent =null, this =com.android.internal.policy.impl.PhoneWindow$DecorView{2b63a461 I.E..... R.....ID 0,0-0,0} D/ViewRootImpl(9949): hardware acceleration is enabled, this = ViewRoot{19e37adf cn.com.antika.business/com.GlamourPromise.Beauty.Business.CompanySelectActivity,ident = 4} V/WindowManager(918): Adding window Window{2281ca08 u0 cn.com.antika.business/com.GlamourPromise.Beauty.Business.CompanySelectActivity} at 7 of 14 (after Window{1b3780a2 u0 cn.com.antika.business/com.GlamourPromise.Beauty.Business.LoginActivity EXITING}) V/PhoneWindow(9949): DecorView setVisiblity: visibility = 0 ,Parent =ViewRoot{19e37adf cn.com.antika.business/com.GlamourPromise.Beauty.Business.CompanySelectActivity,ident = 4}, this =com.android.internal.policy.impl.PhoneWindow$DecorView{2b63a461 V.E..... R.....ID 0,0-0,0} V/WindowManager(918): Changing focus from Window{3eae745 u0 cn.com.antika.business/com.GlamourPromise.Beauty.Business.LoginActivity} to Window{2281ca08 u0 cn.com.antika.business/com.GlamourPromise.Beauty.Business.CompanySelectActivity} Callers=com.android.server.wm.WindowManagerService.relayoutWindow:3993 com.android.server.wm.Session.relayout:203 android.view.IWindowSession$Stub.onTransact:273 com.android.server.wm.Session.onTransact:136 I/WindowManager(918): Gaining focus: Window{2281ca08 u0 cn.com.antika.business/com.GlamourPromise.Beauty.Business.CompanySelectActivity} D/OpenGLRenderer(9949): CanvasContext() 0xf48971c0 initialize 0xf49ca108 D/Surface(9949): Surface::connect(this=0xf49ca100,api=1) D/mali_winsys(9949): new_window_surface returns 0x3000 D/Surface(9949): Surface::allocateBuffers(this=0xf49ca100) D/AbsListView(9949): onSizeChanged w=700, h=1049, oldw=0, oldh=0, getChildCount=0, mSyncPosition=0, mNeedSync=false, mSyncMode=0, mAdapterandroid.widget.ExpandableListConnector@3cc5732c, this=android.widget.ExpandableListView{3dcd67d1 VFED.VC. ......I. 10,195-710,1244 #7f0a018f app:id/company_list}, callstack=android.widget.ListView.onSizeChanged:1156 android.view.View.sizeChange:16199 android.view.View.setFrame:16164 android.widget.AbsListView.setFrame:2308 android.view.View.layout:16055 android.view.ViewGroup.layout:5234 android.widget.LinearLayout.setChildFrame:1959 android.widget.LinearLayout.layoutVertical:1813 android.widget.LinearLayout.onLayout:1722 android.view.View.layout:16065 D/AndroidRuntime(9949): Shutting down VM I/Process(9949): Sending signal. PID: 9949 SIG: 9 D/PSD(377): set_ps_threshold: low_threshold 268 high_threshold 288 ps_average 208 algo_state 1 E/LIGHT(918): AmbiLightSensor: get als value 235 E/LIGHT(918): AmbiLightSensor: report als event E/PROXIMITY(918): ProximitySensor: unknown event (type=3, code=0) E/PROXIMITY(918): ProximitySensor: invalid EV_SYN D/SurfaceFlinger(328): Skip composition. D/SurfaceFlinger(328): Skip composition. E/JavaBinder(918): !!! FAILED BINDER TRANSACTION !!! E/JavaBinder(918): !!! FAILED BINDER TRANSACTION !!! D/GuiExt(384): [GuiExtS] binder of dump tunnel(RB-0xdd4f3380) died I/WindowState(918): WIN DEATH: Window{3eae745 u0 cn.com.antika.business/com.GlamourPromise.Beauty.Business.LoginActivity} I/SurfaceFlinger(328): EventThread Client Pid (9949) disconnected by (328) I/SurfaceFlinger(328): EventThread Client Pid (9949) disconnected by (328) W/ADB_SERVICES(9929): terminating JDWP 9949 connection: Try again I/WindowState(918): WIN DEATH: Window{2281ca08 u0 cn.com.antika.business/com.GlamourPromise.Beauty.Business.CompanySelectActivity} W/ADB_SERVICES(9929): terminating JDWP 9949 connection: Try again I/WindowState(918): WIN DEATH: Window{2281ca08 u0 cn.com.antika.business/com.GlamourPromise.Beauty.Business.CompanySelectActivity} 继续贴日志 V/WindowManager(918): Changing focus from Window{2281ca08 u0 cn.com.antika.business/com.GlamourPromise.Beauty.Business.CompanySelectActivity EXITING} to null Callers=com.android.server.wm.WindowManagerService.removeWindowLocked:3238 com.android.server.wm.WindowState$DeathRecipient.binderDied:1168 android.os.BinderProxy.sendDeathNotice:559 <bottom of call stack> I/WindowManager(918): Losing focus: Window{2281ca08 u0 cn.com.antika.business/com.GlamourPromise.Beauty.Business.CompanySelectActivity EXITING} D/PerfServiceManager(918): [PerfService] MESSAGE_TIMEOUT:107 I/libPerfService(918): [perfScnDisable] scn:1, scn_root_cluster:-1 I/libPerfService(918): [perfScnDisable] scn:6, scn_root_cluster:-1 I/libPerfService(918): 7: set vcore level: 3 D/PerfServiceManager(918): [PerfService] set utilization:0.8 D/SurfaceFlinger(328): Skip composition. I/ActivityManager(918): Process cn.com.antika.business (pid 9949) has died Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:1517 com.android.server.am.OppoExtraActivityManagerService.setKeyLockModeNormal:47 com.android.server.am.ActivityManagerService.appDiedLocked:6305 com.android.server.am.ActivityManagerService$AppDeathRecipient.binderDied:1441 android.os.BinderProxy.sendDeathNotice:559 D/ActivityManager(918): SVC-handleAppDiedLocked: app = ProcessRecord{701a5a1 9949:cn.com.antika.business/u0a126}, app.pid = 9949 I/PPS(918): [PPSNotifyAppState] nPackNum:1, pack:cn.com.antika.business, com:(null), state:3, pid:0, last_boost_tid:-1 D/ForegroundUtils(2208): Process died; UID 10126 PID 9949 W/ActivityManager(918): Force removing ActivityRecord{1f3cd8f u0 cn.com.antika.business/com.GlamourPromise.Beauty.Business.CompanySelectActivity t130}: app died, no saved state D/ForegroundUtils(2208): Foreground changed, PID: 9949 UID: 10126 foreground: false V/NetworkStats(918): setKernelCounterSet uid=10126 set=0 D/ForegroundUtils(2208): Foreground UID/PID combinations: D/ConnectivityService(918): onUidRulesChanged(uid=10126, uidRules=0) D/ActivityManager(918): [BMW] moveNextFloatingStackToTopLocked next = null curTop = ActivityStack{34190215 stackId=1, 14 tasks} D/WindowManager(918): notifyActivityDrawnForKeyguard: waiting=false Callers=com.android.server.wm.WindowManagerService.handleAppTransitionReadyLocked:10689 com.android.server.wm.WindowManagerService.performLayoutAndPlaceSurfacesLockedInner:11319 com.android.server.wm.WindowManagerService.performLayoutAndPlaceSurfacesLockedLoop:10058 com.android.server.wm.WindowManagerService.performLayoutAndPlaceSurfacesLocked:10000 com.android.server.wm.WindowManagerService.moveStackWindowsLocked:6068 W/ContextImpl(918): Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:1517 com.android.server.am.OppoProtectEyeManagerService.sendProtectEyeBroadcast:170 com.android.server.am.OppoProtectEyeManagerService.handleProtectEyeMode:154 com.android.server.am.ActivityStack.resumeTopActivityInnerLocked:2234 com.android.server.am.ActivityStack.resumeTopActivityLocked:1790 I/libPerfService(918): perfSetFavorPid - pid:2360, 938 I/PPS(918): [PPSNotifyAppState] nPackNum:1, pack:com.oppo.launcher, com:.Launcher, state:1, pid:0, last_boost_tid:-1 I/OppoPhoneWindowManager(918): KeyLockModeReceiver KeyLockMode: 0 ProcessName: cn.com.antika.business D/ForegroundUtils(2208): Foreground changed, PID: 2360 UID: 10063 foreground: true V/NetworkStats(918): setKernelCounterSet uid=10063 set=1 D/ForegroundUtils(2208): Foreground UID/PID combinations: D/ConnectivityService(918): onUidRulesChanged(uid=10063, uidRules=0) D/ForegroundUtils(2208): UID: 10063 PID: 2360 D/OpenGLRenderer(2360): Flushing caches (mode 0) D/OpenGLRenderer(2360): Flushing caches (mode 0) D/SurfaceFlinger(328): Skip composition. I/SurfaceFlinger(328): [SF client] DEL(0x7fa3c1d6c0) for (918:system_server) D/SurfaceFlinger(328): remove: cn.com.antika.business/com.GlamourPromise.Beauty.Business.LoginActivity D/SurfaceFlinger(328): remove: cn.com.antika.business/com.GlamourPromise.Beauty.Business.CompanySelectActivity V/PhoneWindow(2360): DecorView setVisiblity: visibility = 0 ,Parent =ViewRoot{213cf907 com.oppo.launcher/com.oppo.launcher.Launcher,ident = 0}, this =com.android.internal.policy.impl.PhoneWindow$DecorView{50d63f8 V.E..... R.....ID 0,0-720,1280} V/WindowManager(918): Changing focus from null to Window{3d235d75 u0 com.oppo.launcher/com.oppo.launcher.Launcher} Callers=com.android.server.wm.WindowManagerService.relayoutWindow:3993 com.android.server.wm.Session.relayout:203 android.view.IWindowSession$Stub.onTransact:273 com.android.server.wm.Session.onTransact:136 I/WindowManager(918): Gaining focus: Window{3d235d75 u0 com.oppo.launcher/com.oppo.launcher.Launcher} D/OpenGLRenderer(2360): CanvasContext() 0x7f8eb387c0 initialize 0x7f8ea72610 D/Surface(2360): Surface::connect(this=0x7f8ea72600,api=1) D/mali_winsys(2360): new_window_surface returns 0x3000 D/Surface(2360): Surface::allocateBuffers(this=0x7f8ea72600) V/InputMethodManager(2360): onWindowFocus: null softInputMode=304 first=true flags=#5900100 V/InputMethodManager(2360): START INPUT: com.android.internal.policy.impl.PhoneWindow$DecorView{50d63f8 V.E..... R.....ID 0,0-720,1280} ic=null tba=android.view.inputmethod.EditorInfo@1ed6e15d controlFlags=#104 V/InputMethodManagerService(918): windowGainedFocus: android.os.BinderProxy@a099631 controlFlags=#104 softInputMode=#130 windowFlags=#5900100 D/InputMethodManagerService(918): unbindCurrentClient send MSG_SET_ACTIVE active: false , to client:ClientState{3d9a3942 uid 10126 pid 9949} D/InputMethodManagerService(918): case MSG_SET_ACTIVE, active:false W/InputMethodManagerService(918): Got RemoteException sending setActive(false) notification to pid 9949 uid 10126 D/InputMethodManagerService(918): startInputUnchecked send MSG_SET_ACTIVE active:true, to client:null D/InputMethodManagerService(918): case MSG_SET_ACTIVE, active:true D/InputMethodManager(2360): receive service's setActive call, active:true I/InputMethodManager(2360): handleMessage: MSG_SET_ACTIVE true, was false D/SurfaceFlinger(328): Skip composition. V/WallpaperService(27833): Visibility change in com.android.systemui.ImageWallpaper$DrawableEngine@20ab8bb1: 1 I/OppoBroadcastManager(918): oppo Broadcast intent Intent { act=com.nav.color flg=0x10 (has extras) } on background queue V/WallpaperService(27833): onVisibilityChanged(true): com.android.systemui.ImageWallpaper$DrawableEngine@20ab8bb1 V/WallpaperService(27833): Offsets change in com.android.systemui.ImageWallpaper$DrawableEngine@20ab8bb1: 0.0,0.0 D/WindowManager(918): notifyActivityDrawnForKeyguard: waiting=false Callers=com.android.server.wm.WindowManagerService.handleAppTransitionReadyLocked:10689 com.android.server.wm.WindowManagerService.performLayoutAndPlaceSurfacesLockedInner:11319 com.android.server.wm.WindowManagerService.performLayoutAndPlaceSurfacesLockedLoop:10058 com.android.server.wm.WindowManagerService.performLayoutAndPlaceSurfacesLocked:10000 com.android.server.wm.WindowManagerService.access$900:216 D/BluetoothAdapter(27833): 870302359: getState() : mService = null. Returning STATE_OFF D/BluetoothAdapter(27833): 870302359: getState() : mService = null. Returning STATE_OFF I/WifiStateMachine(918): fetchRssiLinkSpeedAndFrequencyNative, newRssi:-32, newLinkSpeed:65, SSID:"TP-LINK_CWMD" D/NetworkLinkMonitor(918): RSSI_PKTCNT_FETCH_SUCCEEDED--dtotal= 13

小白求问为什么应用一进去就闪退了

04-17 22:29:38.316 2512-2512/? I/appproc: denglibo exec app_process! cmdline: /system/bin com.android.commands.pm.Pm install -t -r /data/local/tmp/com.example.hasee.myapplication 04-17 22:29:38.316 2512-2512/? D/AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 0 <<<<<< 04-17 22:29:38.317 2512-2512/? D/AndroidRuntime: CheckJNI is OFF 04-17 22:29:38.332 2512-2512/? D/libnativebridge: PreInitializeNativeBridge name=unknown 04-17 22:29:38.359 2512-2512/? E/memtrack: Couldn't load memtrack module (No such file or directory) 04-17 22:29:38.359 2512-2512/? E/android.os.Debug: failed to load memtrack module: -2 04-17 22:29:38.376 2512-2512/? D/AndroidRuntime: Calling main entry com.android.commands.pm.Pm --------- beginning of system 04-17 22:29:38.382 2159-2174/com.android.defcontainer I/NativeHelper: denglibo call findSupportedAbi! abiList=x86 armeabi-v7a armeabi packageName=com.example.hasee.myapplication 04-17 22:29:38.384 2159-2174/com.android.defcontainer D/NativeLibraryHelper: denglibo call LdFindSupportedAbi, param: supportedAbisArray=x86 armeabi-v7a armeabi 04-17 22:29:38.385 2159-2174/com.android.defcontainer D/NativeLibraryHelper: denglibo native LdFindSupportedAbi return! ret=-114 abi=NULL 04-17 22:29:38.388 2159-2173/com.android.defcontainer D/DefContainer: Copying /data/local/tmp/com.example.hasee.myapplication to base.apk 04-17 22:29:38.393 1541-1570/system_process I/NativeHelper: denglibo call findSupportedAbi! abiList=x86 armeabi-v7a armeabi packageName=com.example.hasee.myapplication 04-17 22:29:38.395 1541-1570/system_process D/NativeLibraryHelper: denglibo call LdFindSupportedAbi, param: supportedAbisArray=x86 armeabi-v7a armeabi 04-17 22:29:38.396 1541-1570/system_process D/NativeLibraryHelper: denglibo native LdFindSupportedAbi return! ret=-114 abi=NULL 04-17 22:29:38.409 1541-1570/system_process D/PackageManager: Renaming /data/app/vmdl270166158.tmp to /data/app/com.example.hasee.myapplication-2 04-17 22:29:38.410 1541-1561/system_process I/ActivityManager: Force stopping com.example.hasee.myapplication appid=10031 user=-1: uninstall pkg 04-17 22:29:38.417 1541-1570/system_process I/PackageManager: denglibo-scanPackageDirtyLI oldSeting(packages.xml): com.example.hasee.myapplication orig primaryCpuAbi: null secondaryCpuAbi: null cpuAbiOverride: null myOrigCpuAbi: null 04-17 22:29:38.417 1541-1570/system_process I/PackageManager: Package com.example.hasee.myapplication codePath changed from /data/app/com.example.hasee.myapplication-1 to /data/app/com.example.hasee.myapplication-2; Retaining data and using new 04-17 22:29:38.424 1541-1570/system_process I/NativeHelper: denglibo call findSupportedAbi! abiList=x86 armeabi-v7a armeabi packageName=com.example.hasee.myapplication 04-17 22:29:38.427 1541-1570/system_process D/NativeLibraryHelper: denglibo call LdFindSupportedAbi, param: supportedAbisArray=x86 armeabi-v7a armeabi 04-17 22:29:38.427 1541-1570/system_process D/NativeLibraryHelper: denglibo native LdFindSupportedAbi return! ret=-114 abi=NULL 04-17 22:29:38.428 1541-1570/system_process I/PackageManager: denglibo-copyNativeBinariesForSupportedAbi finish: copyRet = -114 04-17 22:29:38.428 1541-1570/system_process I/PackageManager: Running dexopt on: /data/app/com.example.hasee.myapplication-2/base.apk pkg=com.example.hasee.myapplication isa=x86 vmSafeMode=false 04-17 22:29:38.437 2523-2523/? I/dex2oat: /system/bin/dex2oat --zip-fd=5 --zip-location=/data/app/com.example.hasee.myapplication-2/base.apk --oat-fd=6 --oat-location=/data/dalvik-cache/x86/data@app@com.example.hasee.myapplication-2@base.apk@classes.dex --instruction-set=x86 --instruction-set-features=default --runtime-arg -Xms64m --runtime-arg -Xmx512m --swap-fd=7 04-17 22:29:38.439 2523-2523/? E/libnativebridge: denglibol LoadNativeBridge error! nb_library_filename invalid! 04-17 22:29:38.517 2523-2523/? I/dex2oat: Decided to run without swap. 04-17 22:29:38.539 2523-2523/? W/dex2oat: Before Android 4.1, method int android.support.v7.widget.DropDownListView.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView 04-17 22:29:38.558 2523-2525/? W/dex2oat: Before Android 4.1, method int android.support.v7.widget.MenuPopupWindow$MenuDropDownListView.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView 04-17 22:29:38.560 2523-2525/? W/dex2oat: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable 04-17 22:29:39.453 2523-2523/? I/dex2oat: dex2oat took 1.015s (threads: 2) arena alloc=306KB java alloc=3MB native alloc=6MB free=9MB 04-17 22:29:39.454 1541-1570/system_process W/PackageManager: Code path for pkg : com.example.hasee.myapplication changing from /data/app/com.example.hasee.myapplication-1 to /data/app/com.example.hasee.myapplication-2 04-17 22:29:39.454 1541-1570/system_process W/PackageManager: Resource path for pkg : com.example.hasee.myapplication changing from /data/app/com.example.hasee.myapplication-1 to /data/app/com.example.hasee.myapplication-2 04-17 22:29:39.455 1541-1561/system_process I/ActivityManager: Force stopping com.example.hasee.myapplication appid=10031 user=-1: update pkg 04-17 22:29:39.464 1541-1570/system_process I/ActivityManager: Force stopping com.example.hasee.myapplication appid=10031 user=0: pkg removed 04-17 22:29:39.471 1752-1752/com.android.launcher3 I/art: Explicit concurrent mark sweep GC freed 1842(105KB) AllocSpace objects, 3(108KB) LOS objects, 39% free, 11MB/19MB, paused 137us total 6.681ms 04-17 22:29:39.473 1994-1994/com.android.flysilkworm I/art: Explicit concurrent mark sweep GC freed 165(6KB) AllocSpace objects, 1(36KB) LOS objects, 24% free, 8MB/11MB, paused 126us total 6.168ms 04-17 22:29:39.478 1644-1644/com.android.systemui I/art: Explicit concurrent mark sweep GC freed 17097(644KB) AllocSpace objects, 0(0B) LOS objects, 39% free, 16MB/27MB, paused 156us total 13.779ms 04-17 22:29:39.485 1541-1587/system_process I/InputReader: Reconfiguring input devices. changes=0x00000010 04-17 22:29:39.486 1541-1587/system_process I/InputReader: Reconfiguring input devices. changes=0x00000010 04-17 22:29:39.487 1714-1714/com.android.emu.coreservice I/EmuCoreService: Broadcast action = android.intent.action.PACKAGE_REMOVED 04-17 22:29:39.491 1541-1570/system_process W/Settings: Setting install_non_market_apps has moved from android.provider.Settings.Global to android.provider.Settings.Secure, returning read-only value. 04-17 22:29:39.491 1541-1587/system_process I/InputReader: Reconfiguring input devices. changes=0x00000010 04-17 22:29:39.492 2093-2093/com.android.keychain W/ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.startService:1692 android.content.ContextWrapper.startService:516 android.content.ContextWrapper.startService:516 com.android.keychain.KeyChainBroadcastReceiver.onReceive:12 android.app.ActivityThread.handleReceiver:2609 04-17 22:29:39.493 1752-1752/com.android.launcher3 W/Launcher: setApplicationContext called twice! old=com.android.launcher3.LauncherApplication@22977308 new=com.android.launcher3.LauncherApplication@22977308 04-17 22:29:39.494 1541-1560/system_process W/Searchables: No global search activity found 04-17 22:29:39.503 1541-1541/system_process I/art: Explicit concurrent mark sweep GC freed 83651(4MB) AllocSpace objects, 29(1129KB) LOS objects, 33% free, 15MB/23MB, paused 1.088ms total 29.050ms 04-17 22:29:39.503 1541-1541/system_process D/JobSchedulerService: Receieved: android.intent.action.PACKAGE_REMOVED 04-17 22:29:39.503 1541-1541/system_process D/BackupManagerService: Received broadcast Intent { act=android.intent.action.PACKAGE_REMOVED dat=package:com.example.hasee.myapplication flg=0x4000010 (has extras) } 04-17 22:29:39.504 1541-1570/system_process I/art: WaitForGcToComplete blocked for 12.932ms for cause Explicit 04-17 22:29:39.512 1994-1994/com.android.flysilkworm I/appstore: app Not Started 04-17 22:29:39.512 1541-1541/system_process D/BackupManagerService: Received broadcast Intent { act=android.intent.action.PACKAGE_ADDED dat=package:com.example.hasee.myapplication flg=0x4000010 (has extras) } 04-17 22:29:39.512 1541-1541/system_process W/BackupManagerService: Removing schedule queue dupe of com.example.hasee.myapplication 04-17 22:29:39.513 1541-1560/system_process W/Searchables: No global search activity found 04-17 22:29:39.515 1541-1560/system_process W/VoiceInteractionManagerService: no available voice recognition services found for user 0 04-17 22:29:39.515 1714-1714/com.android.emu.coreservice I/EmuCoreService: Broadcast action = android.intent.action.PACKAGE_ADDED 04-17 22:29:39.527 1541-1753/system_process W/BackupManagerService: dataChanged but no participant pkg='com.android.launcher3' uid=10020 04-17 22:29:39.536 1994-1994/com.android.flysilkworm I/appstore: app Not Started 04-17 22:29:39.539 1752-1752/com.android.launcher3 W/Launcher: setApplicationContext called twice! old=com.android.launcher3.LauncherApplication@22977308 new=com.android.launcher3.LauncherApplication@22977308 04-17 22:29:39.542 1541-1570/system_process I/art: Explicit concurrent mark sweep GC freed 5719(344KB) AllocSpace objects, 0(0B) LOS objects, 33% free, 15MB/23MB, paused 1.145ms total 38.299ms 04-17 22:29:39.546 2512-2512/? I/art: System.exit called, status: 0 04-17 22:29:39.547 2512-2512/? I/AndroidRuntime: VM exiting with result code 0. 04-17 22:29:39.628 1994-2199/com.android.flysilkworm I/System.out: 200 04-17 22:29:39.655 2536-2536/? I/appproc: denglibo exec app_process! cmdline: /system/bin com.android.commands.am.Am start -n com.example.hasee.myapplication/com.example.hasee.myapplication.MainActivity -a android.intent.action.MAIN -c android.intent.category.LAUNCHER 04-17 22:29:39.655 2536-2536/? D/AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 0 <<<<<< 04-17 22:29:39.657 2536-2536/? D/AndroidRuntime: CheckJNI is OFF 04-17 22:29:39.667 2536-2536/? D/libnativebridge: PreInitializeNativeBridge name=unknown 04-17 22:29:39.679 2536-2536/? E/memtrack: Couldn't load memtrack module (No such file or directory) 04-17 22:29:39.679 2536-2536/? E/android.os.Debug: failed to load memtrack module: -2 04-17 22:29:39.694 2536-2536/? D/AndroidRuntime: Calling main entry com.android.commands.am.Am 04-17 22:29:39.718 1541-1555/system_process I/ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.hasee.myapplication/.MainActivity} from uid 0 on display 0 04-17 22:29:39.719 1541-1555/system_process V/WindowManager: addAppToken: AppWindowToken{362f7eb7 token=Token{2ac5a1b6 ActivityRecord{18688551 u0 com.example.hasee.myapplication/.MainActivity t7}}} to stack=1 task=7 at 0 04-17 22:29:39.720 1541-1566/system_process V/WindowManager: Adding window Window{3c93318e u0 Starting com.example.hasee.myapplication} at 2 of 5 (after Window{fa9636f u0 com.android.launcher3/com.android.launcher3.Launcher}) 04-17 22:29:39.721 2536-2536/? D/AndroidRuntime: Shutting down VM 04-17 22:29:39.721 2536-2536/? D/libnativebridge: call UnloadNativeBridge! state=1 04-17 22:29:39.730 1541-1555/system_process I/ActivityManager: Start proc 2546:com.example.hasee.myapplication/u0a31 for activity com.example.hasee.myapplication/.MainActivity 04-17 22:29:39.731 1714-1714/com.android.emu.coreservice I/EmuCoreService: Broadcast action = android.intent.action.TOP_ACTIVITY_CHANGED 04-17 22:29:39.748 2546-2546/? I/art: Late-enabling -Xcheck:jni 04-17 22:29:39.748 2546-2546/? D/libnativebridge: call UnloadNativeBridge! state=1 04-17 22:29:39.768 2546-2554/? I/art: Debugger is no longer active 04-17 22:29:39.861 2546-2546/? D/AndroidRuntime: Shutting down VM --------- beginning of crash 04-17 22:29:39.861 2546-2546/? E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.hasee.myapplication, PID: 2546 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.hasee.myapplication/com.example.hasee.myapplication.MainActivity}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list' at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) at android.app.ActivityThread.access$800(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5254) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700) Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list' at android.app.ListActivity.onContentChanged(ListActivity.java:243) at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:382) at android.app.Activity.setContentView(Activity.java:2145) at com.example.hasee.myapplication.MainActivity.onCreate(MainActivity.java:34) at android.app.Activity.performCreate(Activity.java:5990) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)  at android.app.ActivityThread.access$800(ActivityThread.java:151)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:135)  at android.app.ActivityThread.main(ActivityThread.java:5254)  at java.lang.reflect.Method.invoke(Native Method)  at java.lang.reflect.Method.invoke(Method.java:372)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)  04-17 22:29:39.861 1541-1708/system_process W/ActivityManager: Force finishing activity 1 com.example.hasee.myapplication/.MainActivity 04-17 22:29:39.951 1752-2049/com.android.launcher3 D/EGL_adreno: eglMakeCurrent: 0xaec34760: ver 3 1 (tinfo 0xaec395f0) 04-17 22:29:40.069 1365-1365/? E/EGL_adreno: tid 1365: eglCreateSyncKHR(1987): error 0x3004 (EGL_BAD_ATTRIBUTE) 04-17 22:29:40.074 1541-1541/system_process W/art: Long monitor contention event with owner method=void com.android.server.am.ActivityManagerService.crashApplication(com.android.server.am.ProcessRecord, android.app.ApplicationErrorReport$CrashInfo) from ActivityManagerService.java:12135 waiters=0 for 211ms 04-17 22:29:40.074 1541-1561/system_process W/System.err: java.lang.Exception: denglibo show AlertDialog! title= 04-17 22:29:40.074 1541-1561/system_process W/System.err: at android.app.AlertDialog.show(AlertDialog.java:112) 04-17 22:29:40.074 1541-1561/system_process W/System.err: at com.android.server.am.ActivityManagerService$MainHandler.handleMessage(ActivityManagerService.java:1342) 04-17 22:29:40.074 1541-1561/system_process W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102) 04-17 22:29:40.074 1541-1561/system_process W/System.err: at android.os.Looper.loop(Looper.java:135) 04-17 22:29:40.074 1541-1561/system_process W/System.err: at android.os.HandlerThread.run(HandlerThread.java:61) 04-17 22:29:40.074 1541-1561/system_process W/System.err: at com.android.server.ServiceThread.run(ServiceThread.java:46) 04-17 22:29:40.106 1541-2235/system_process I/OpenGLRenderer: Initialized EGL, version 1.4 04-17 22:29:40.106 1541-2235/system_process I/EGL_adreno: eglCreateContext request GLES major-version=2 04-17 22:29:40.107 1541-2235/system_process D/EGL_adreno: eglCreateContext: 0x9edfe9a0: maj 3 min 1 rcv 4 04-17 22:29:40.111 1541-2235/system_process D/EGL_adreno: eglMakeCurrent: 0x9edfe9a0: ver 3 1 (tinfo 0xa22f8770) 04-17 22:29:40.118 1541-2235/system_process E/EGL_adreno: tid 2235: eglSurfaceAttrib(1266): error 0x3009 (EGL_BAD_MATCH) 04-17 22:29:40.118 1541-2235/system_process W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xaec22700, error=EGL_BAD_MATCH 04-17 22:29:40.119 1541-2235/system_process D/EGL_adreno: eglMakeCurrent: 0x9edfe9a0: ver 3 1 (tinfo 0xa22f8770) 04-17 22:29:40.574 1541-1561/system_process W/ActivityManager: Activity pause timeout for ActivityRecord{18688551 u0 com.example.hasee.myapplication/.MainActivity t7 f} 04-17 22:29:40.577 1714-1714/com.android.emu.coreservice I/EmuCoreService: Broadcast action = android.intent.action.TOP_ACTIVITY_CHANGED 04-17 22:29:40.593 1752-2049/com.android.launcher3 I/OpenGLRenderer: Initialized EGL, version 1.4 04-17 22:29:40.594 1752-2049/com.android.launcher3 I/EGL_adreno: eglCreateContext request GLES major-version=2 04-17 22:29:40.595 1752-2049/com.android.launcher3 D/EGL_adreno: eglCreateContext: 0xaec34760: maj 3 min 1 rcv 4 04-17 22:29:40.602 1752-2049/com.android.launcher3 D/EGL_adreno: eglMakeCurrent: 0xaec34760: ver 3 1 (tinfo 0xaec395f0) 04-17 22:29:40.615 1752-2049/com.android.launcher3 E/EGL_adreno: tid 2049: eglSurfaceAttrib(1266): error 0x3009 (EGL_BAD_MATCH) 04-17 22:29:40.615 1752-2049/com.android.launcher3 W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xaec601a0, error=EGL_BAD_MATCH 04-17 22:29:40.616 1752-2049/com.android.launcher3 D/EGL_adreno: eglMakeCurrent: 0xaec34760: ver 3 1 (tinfo 0xaec395f0) 04-17 22:29:40.662 1752-2049/com.android.launcher3 V/RenderScript: 0xaedacc00 Launching thread(s), CPUs 2 04-17 22:29:40.798 1541-1595/system_process E/WifiStateMachine: WifiStateMachine CMD_START_SCAN source -2 txSuccessRate=0.00 rxSuccessRate=0.00 targetRoamBSSID=00:81:ec:72:db:e9 RSSI=-45 04-17 22:29:41.146 1752-2049/com.android.launcher3 D/EGL_adreno: eglMakeCurrent: 0xaec34760: ver 3 1 (tinfo 0xaec395f0) 04-17 22:29:41.157 1752-2049/com.android.launcher3 D/EGL_adreno: eglMakeCurrent: 0xaec34760: ver 3 1 (tinfo 0xaec395f0) 04-17 22:29:41.160 1752-2049/com.android.launcher3 D/EGL_adreno: eglMakeCurrent: 0xaec34760: ver 3 1 (tinfo 0xaec395f0) 04-17 22:29:41.160 1752-2049/com.android.launcher3 W/OpenGLRenderer: Incorrectly called buildLayer on View: ShortcutAndWidgetContainer, destroying layer... 04-17 22:29:41.161 1752-2049/com.android.launcher3 D/EGL_adreno: eglMakeCurrent: 0xaec34760: ver 3 1 (tinfo 0xaec395f0) 04-17 22:29:41.578 1644-1644/com.android.systemui W/ResourceType: No package identifier when getting value for resource number 0x00000000 04-17 22:29:41.578 1644-1644/com.android.systemui W/PackageManager: Failure retrieving resources for com.example.hasee.myapplication: Resource ID #0x0 04-17 22:29:50.691 1541-1561/system_process W/ActivityManager: Activity destroy timeout for ActivityRecord{18688551 u0 com.example.hasee.myapplication/.MainActivity t7 f} 04-17 22:29:59.192 1365-1515/? E/SurfaceFlinger: warning, detect vsync overflow! 04-17 22:30:00.041 1365-1515/? E/SurfaceFlinger: warning, detect vsync overflow! 04-17 22:30:00.801 1541-1595/system_process E/WifiStateMachine: WifiStateMachine CMD_START_SCAN source -2 txSuccessRate=0.00 rxSuccessRate=0.00 targetRoamBSSID=00:81:ec:72:db:e9 RSSI=-45 04-17 22:30:20.806 1541-1595/system_process E/WifiStateMachine: WifiStateMachine CMD_START_SCAN source -2 txSuccessRate=0.00 rxSuccessRate=0.00 targetRoamBSSID=00:81:ec:72:db:e9 RSSI=-45 04-17 22:30:40.811 1541-1595/system_process E/WifiStateMachine: WifiStateMachine CMD_START_SCAN source -2 txSuccessRate=0.00 rxSuccessRate=0.00 targetRoamBSSID=00:81:ec:72:db:e9 RSSI=-45 04-17 22:31:00.816 1541-1595/system_process E/WifiStateMachine: WifiStateMachine CMD_START_SCAN source -2 txSuccessRate=0.00 rxSuccessRate=0.00 targetRoamBSSID=00:81:ec:72:db:e9 RSSI=-45 04-17 22:31:20.817 1541-1595/system_process E/WifiStateMachine: WifiStateMachine CMD_START_SCAN source -2 txSuccessRate=0.00 rxSuccessRate=0.00 targetRoamBSSID=00:81:ec:72:db:e9 RSSI=-45 04-17 22:31:20.920 1541-1595/system_process E/WifiStateMachine: denglibo mScanResults.size=1 04-17 22:31:20.920 1541-1595/system_process I/LdWifi: ld_get_eth0_ip return 172.16.2.15 04-17 22:31:40.821 1541-1595/system_process E/WifiStateMachine: WifiStateMachine CMD_START_SCAN source -2 txSuccessRate=0.00 rxSuccessRate=0.00 targetRoamBSSID=00:81:ec:72:db:e9 RSSI=-45 04-17 22:32:00.824 1541-1595/system_process E/WifiStateMachine: WifiStateMachine CMD_START_SCAN source -2 txSuccessRate=0.00 rxSuccessRate=0.00 targetRoamBSSID=00:81:ec:72:db:e9 RSSI=-45 04-17 22:32:20.827 1541-1595/system_process E/WifiStateMachine: WifiStateMachine CMD_START_SCAN source -2 txSuccessRate=0.00 rxSuccessRate=0.00 targetRoamBSSID=00:81:ec:72:db:e9 RSSI=-45

代码没有报错但是程序一运行就崩溃

``` public class WareShow extends Activity { private String[] bookname = new String[]{"从你的全世界路过","59秒的转动","心理罪","肖申克的救赎","疯狂Android讲义"}; private String[] penname = new String[]{"张嘉佳","周语","雷米","斯蒂芬","李刚"}; private String[] price = new String[]{"32¥","38¥","29¥","56¥","35¥"}; private int[] imageIds = new int[]{R.drawable.bg_01, R.drawable.bg_04, R.drawable.bg_02, R.drawable.bg_05, R.drawable.bg_03}; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.book); List<Map<String,Object>> listItem = new ArrayList<Map<String,Object>>(); for (int i = 0; i < bookname.length; i++) { Map<String, Object> listItem1 = new HashMap<String,Object>(); listItem1.put("book", bookname[i]); listItem1.put("pen", penname[i]); listItem1.put("money", price); listItem1.put("image", imageIds); } SimpleAdapter simpleAdapter = new SimpleAdapter(this,listItem,R.layout.book,new String[]{"book","pen","money","image"},new int[]{R.id.imageIds,R.id.tv1,R.id.tv2,R.id.tv3}); ListView listView = (ListView) findViewById(R.id.lv1); listView.setAdapter(simpleAdapter); } } ``` 这段代码没有报错但是运行时程序崩溃了

运行到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; } } ```

android 中自定义GridView的使用

楼主最近在学习安卓,用和ListView类似的方法实现Gridview的时候出现了问题。希望高手能指点一二。 aty_using_gridview.xml ``` <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <GridView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/gridView" android:numColumns="3"/> </LinearLayout> ``` grid_view_cell.xml ``` <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="100dp" android:layout_height="100dp"> <ImageView android:layout_width="100dp" android:layout_height="100dp" android:id="@+id/img_grid_view" /> </FrameLayout> ``` 这个是Activity ``` public class AtyUsingGridView extends Activity { private GridView gridView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.aty_using_gridview); ImageGridViewAdapter adapter=new ImageGridViewAdapter(this); gridView.findViewById(R.id.gridView); gridView.setAdapter(adapter); } } ``` 这个是adapter ``` public class ImageGridViewAdapter extends BaseAdapter { private Context context=null; private ImageGridViewData data[]= { new ImageGridViewData( R.drawable.img2), new ImageGridViewData(R.drawable.img2), new ImageGridViewData( R.drawable.img2), }; public ImageGridViewAdapter(Context context){ this.context=context; } public Context getContext() { return context; } @Override public int getCount() { return data.length; } @Override public ImageGridViewData getItem(int i) { return data[i]; } @Override public long getItemId(int i) { return i; } @Override public View getView(int i, View view, ViewGroup viewGroup) { FrameLayout fl=null; if(view!=null){ fl=( FrameLayout)view; }else{ fl= ( FrameLayout) LayoutInflater.from(getContext()).inflate(R.layout.grid_view_cell,null); } ImageGridViewData data=getItem(i); ImageView imgID=(ImageView)fl.findViewById(R.id.img_grid_view); imgID.setImageResource(data.imgID); return fl; } } ``` 运行出现错误如下 Unable to start activity java.lang.NullPointerException 我这有什么错误,希望高手给指出啊,万分感谢。

android studio做了个APP,其它用了JSOUP,碰到dopostback函数,无法加载

HfztbAcitivity package linpeng.ztb; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import android.app.Activity; import android.app.AlertDialog.Builder; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.graphics.Color; import android.graphics.drawable.ColorDrawable; import android.opengl.Visibility; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.util.Log; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.view.Window; import android.view.animation.AlphaAnimation; import android.view.animation.Animation; import android.view.animation.AnimationSet; import android.view.animation.RotateAnimation; import android.view.animation.ScaleAnimation; import android.view.animation.TranslateAnimation; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.Button; import android.widget.GridView; import android.widget.HorizontalScrollView; import android.widget.ListView; import android.widget.ProgressBar; import android.widget.SimpleAdapter; import android.widget.TextView; import android.widget.Toast; public class HfztbActivity extends Activity implements OnClickListener { private GridView xml_gridview; private ListView xml_newslist; private Button foot_loadmore, prepare_refresh, gotoright, up, down, gotoother, gotoother2, gotoother3, gotoother4, gotoother5; private TextView foot_text; private ProgressBar foot_progressbar; private HorizontalScrollView horizontalScrollView; private SimpleAdapter listview_adapter; private ProgressBar refresh; private String list_button = "title1"; private int changenewslist = 1; private int[][] location = new int[5][2]; private boolean fist_open_title1 = true, fist_open_title2 = true, fist_open_title3 = true, fist_open_title4 = true, fist_open_title5 = true, goto_other_visiably = false;//fist_open_title6 = true, //fist_open_title7 = true, private boolean is_first_open = true; private final int FLINGDIS = 900; private List<Map<String, Object>> newslist = new ArrayList<Map<String, Object>>(); private List<Map<String, Object>> tempnewslist = new ArrayList<Map<String, Object>>(); private Handler handler = new Handler() { @Override public void handleMessage(Message msg) { if (msg.arg1 > -1) { prepare_refresh.setVisibility(0); refresh.setVisibility(8); Log.i("list_button", new IntToStrong().getname(msg.arg1) + list_button); changeFirstOpen(msg.arg1); if (list_button.equals(new IntToStrong().getname(msg.arg1))) { getNewsList(msg.arg1, false); } } if (msg.arg1 == -1) { prepare_refresh.setVisibility(0); refresh.setVisibility(8); Toast.makeText(HfztbActivity.this, "网络不通,请稍候再试", Toast.LENGTH_SHORT).show(); } } private void changeFirstOpen(int arg1) { if (arg1 == 0 && fist_open_title1) { fist_open_title1 = false; } else if (arg1 == 1 && fist_open_title2) { fist_open_title2 = false; } else if (arg1 == 2 && fist_open_title3) { fist_open_title3 = false; } else if (arg1 == 3 && fist_open_title4) { fist_open_title4 = false; } else if (arg1 == 4 && fist_open_title5) { fist_open_title5 = false; // } else if (arg1 == 5 && fist_open_title6) { // fist_open_title6 = false; // } else if (arg1 == 6 && fist_open_title7) { // fist_open_title7 = false; } } }; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.main); xml_gridview = (GridView) findViewById(R.id.xml_gridview); xml_gridview.setSelector(new ColorDrawable(Color.TRANSPARENT)); xml_newslist = (ListView) findViewById(R.id.newslist); prepare_refresh = (Button) findViewById(R.id.prepare_refresh); refresh = (ProgressBar) findViewById(R.id.refresh); gotoright = (Button) findViewById(R.id.gotoright); horizontalScrollView = (HorizontalScrollView) findViewById(R.id.horizontalScrollView); up = (Button) findViewById(R.id.up); down = (Button) findViewById(R.id.down); gotoother = (Button) findViewById(R.id.gotoother); gotoother2 = (Button) findViewById(R.id.gotoother2); gotoother3 = (Button) findViewById(R.id.gotoother3); gotoother4 = (Button) findViewById(R.id.gotoother4); gotoother5 = (Button) findViewById(R.id.gotoother5); LayoutInflater layoutInflater = getLayoutInflater(); View footView = layoutInflater.inflate(R.layout.foot, null); xml_newslist.addFooterView(footView); foot_loadmore = (Button) findViewById(R.id.foot_loadmore); foot_text = (TextView) findViewById(R.id.foot_text); foot_progressbar = (ProgressBar) findViewById(R.id.foot_progressbar); foot_loadmore.setOnClickListener(this); prepare_refresh.setOnClickListener(this); gotoright.setOnClickListener(this); up.setOnClickListener(this); down.setOnClickListener(this); gotoother.setOnClickListener(this); gotoother2.setOnClickListener(this); gotoother3.setOnClickListener(this); gotoother4.setOnClickListener(this); gotoother5.setOnClickListener(this); getNewsList(0, false); SimpleAdapter gridview_adapter = new SimpleAdapter(this, new ListData().getGridviewdata(), R.layout.gridview, new String[] { "grid_title" }, new int[] { R.id.grid_title }); listview_adapter = new SimpleAdapter(this, newslist, R.layout.newslistdetails, new String[] { "news_isend", "news_title", "news_time" }, new int[] { R.id.news_isend, R.id.news_title, R.id.news_time }); is_first_open = false; xml_gridview.setAdapter(gridview_adapter); xml_gridview.setOnItemClickListener(new onGridViewItemClick()); xml_newslist.setOnItemClickListener(new onListViewItemClick()); xml_newslist.setAdapter(listview_adapter); } private void getloction() { gotoother.getLocationOnScreen(location[0]); gotoother2.getLocationOnScreen(location[1]); gotoother3.getLocationOnScreen(location[2]); gotoother4.getLocationOnScreen(location[3]); gotoother5.getLocationOnScreen(location[4]); Log.i("x", location[0][0] + " " + location[0][1]); } private void getNewsList(int table_number, boolean is_fresh) { boolean has_fresh = false; String table_name = new IntToStrong().getname(table_number); DataBaseHelper dbh = new DataBaseHelper(this, table_name, null, 1); SQLiteDatabase sql = dbh.getReadableDatabase(); Cursor cursor = sql.query(table_name, new String[] { "newsclass", "newstitle", "newstime", "isread" }, "newsclass>?", new String[] { "-1" }, null, null, null); if (cursor.getCount() != 0 && is_fresh == false) { newslist.clear(); getNewsListByDatabase(cursor); prepare_refresh.setVisibility(0); refresh.setVisibility(8); if (!is_first_open) { listview_adapter.notifyDataSetChanged(); xml_newslist.setSelection(0); list_button = new IntToStrong().getname(table_number); } } else { list_button = new IntToStrong().getname(table_number); MyThread myThread = new MyThread(table_number, HfztbActivity.this); has_fresh = true; myThread.start(); } if (!has_fresh) { reFresh(table_name, table_number); } if (sql != null) { sql.close(); } if (dbh != null) { dbh.close(); } } private void reFresh(String table_name, int table_number) { if (fist_open_title1 && table_name == "title1") { MyThread myThread = new MyThread(table_number, HfztbActivity.this); myThread.start(); } else if (fist_open_title2 && table_name == "title2") { MyThread myThread = new MyThread(table_number, HfztbActivity.this); myThread.start(); } else if (fist_open_title3 && table_name == "title3") { MyThread myThread = new MyThread(table_number, HfztbActivity.this); myThread.start(); } else if (fist_open_title4 && table_name == "title4") { MyThread myThread = new MyThread(table_number, HfztbActivity.this); myThread.start(); } else if (fist_open_title5 && table_name == "title5") { MyThread myThread = new MyThread(table_number, HfztbActivity.this); myThread.start(); //} else if (fist_open_title6 && table_name == "title6") { // MyThread myThread = new MyThread(table_number, HfztbActivity.this); // myThread.start(); //} else if (fist_open_title7 && table_name == "title7") { // MyThread myThread = new MyThread(table_number, HfztbActivity.this); // myThread.start(); } } private void getNewsListByDatabase(Cursor cursor) { newslist.clear(); while (cursor.moveToNext()) { Map<String, Object> map = new HashMap<String, Object>(); map.put("news_title", cursor.getString(cursor.getColumnIndex("newstitle"))); map.put("news_time", cursor.getString(cursor.getColumnIndex("newstime"))); map.put("news_isend", cursor.getString(cursor.getColumnIndex("isread"))); newslist.add(map); } } class onGridViewItemClick implements OnItemClickListener { public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { int table_number = arg2; TextView gridviewback = (TextView) arg1; for (int i = 0; i < arg0.getCount(); i++) { TextView gridview_text_temp = (TextView) arg0.getChildAt(i); gridview_text_temp.setBackgroundDrawable(null); gridview_text_temp.setTextColor(getResources().getColor( R.color.grid_title_color)); } gridviewback.setBackgroundResource(R.drawable.gridviewbackground); gridviewback.setTextColor(Color.WHITE); if (arg2 >= 0 && arg2 <= 6) { getNewsList(table_number, false); Log.i("after", "thread"); } } } class onListViewItemClick implements OnItemClickListener { public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { DataBaseHelper dbh = new DataBaseHelper(HfztbActivity.this, list_button, null, 1); SQLiteDatabase sq = dbh.getReadableDatabase(); Cursor cursor = sq.query(list_button, new String[] { "newsclass", "newstitle", "newstime", "isread", "url" }, "newsclass=?", new String[] { arg2 + "" }, null, null, null); cursor.moveToNext(); Intent intent = new Intent(HfztbActivity.this, News.class);// ��ת������ҳ if (!cursor.isAfterLast()) { intent.putExtra("newsurl", cursor.getString(cursor.getColumnIndex("url"))); intent.putExtra("newstitle", cursor.getString(cursor.getColumnIndex("newstitle"))); intent.putExtra("newstime", cursor.getString(cursor.getColumnIndex("newstime"))); intent.putExtra("type", list_button); startActivity(intent); } if (dbh != null) { dbh.close(); sq.close(); } } } public class MyThread extends Thread { private int table_number; private Context context; public MyThread(int table_number, Context context) { this.table_number = table_number; this.context = context; } @Override public void run() { getNewsList(table_number); } protected void getNewsList(int table_number) { try { Document doc; String url = "http://ggzy.jiangxi.gov.cn/jxzbw/jyxx/002004/00200400" + (table_number + 1) + "/MoreInfo.aspx?CategoryNum=00200400"+ (table_number + 1); doc = Jsoup.connect(url).get(); new ListData().getListData(doc, table_number, context, url); Message msg = handler.obtainMessage(); msg.arg1 = table_number; handler.sendMessage(msg); } catch (IOException e) { Log.i("tag", "error"); Message msg = handler.obtainMessage(); msg.arg1 = -1; handler.sendMessage(msg); e.printStackTrace(); } } } public void onClick(View v) { if (v.getId() == foot_loadmore.getId()) { foot_loadmore.setVisibility(8); foot_text.setVisibility(0); foot_progressbar.setVisibility(0); } if (v.getId() == prepare_refresh.getId()) { prepare_refresh.setVisibility(8); refresh.setVisibility(0); getNewsList(new IntToStrong().table_name_to_int(list_button), true); } if (v.getId() == gotoright.getId()) { horizontalScrollView.fling(FLINGDIS); Log.i("" + horizontalScrollView.getScrollY(), horizontalScrollView.getScrollX() + ""); } if (v.getId() == up.getId()) { xml_newslist.setSelection(0); } if (v.getId() == down.getId()) { Log.i("asff", xml_newslist.getScrollY() + ""); xml_newslist.setSelection(1000); } if (v.getId() == gotoother.getId()) { getloction(); if (!goto_other_visiably) { setVisiablyAndAnimation(false, -1); } else { Log.i("x", location[0][0] + " " + location[0][1]); setVisiablyAndAnimation(true, 0); } } if (v.getId() == gotoother2.getId()) { setVisiablyAndAnimation(false, 0); } if (v.getId() == gotoother3.getId()) { setVisiablyAndAnimation(false, 1); } if (v.getId() == gotoother4.getId()) { setVisiablyAndAnimation(false, 2); } if (v.getId() == gotoother5.getId()) { setVisiablyAndAnimation(false, 3); } } private void setVisiablyAndAnimation(boolean b, int which) { if (!b && which > -1) { ScaleAnimation[] scaleAnimations = getScaleAnimation(which); gotoother2.startAnimation(scaleAnimations[0]); gotoother3.startAnimation(scaleAnimations[1]); gotoother4.startAnimation(scaleAnimations[2]); gotoother5.startAnimation(scaleAnimations[3]); gotoother2.setVisibility(8); gotoother3.setVisibility(8); gotoother4.setVisibility(8); gotoother5.setVisibility(8); goto_other_visiably = false; } else if (which == -1) { TranslateAnimation[] translateAnimations = getTranslateAnimation(which); gotoother2.startAnimation(translateAnimations[0]); gotoother3.startAnimation(translateAnimations[1]); gotoother4.startAnimation(translateAnimations[2]); gotoother5.startAnimation(translateAnimations[3]); gotoother2.setVisibility(0); gotoother3.setVisibility(0); gotoother4.setVisibility(0); gotoother5.setVisibility(0); goto_other_visiably = true; } else { TranslateAnimation[] translateAnimations = getTranslateAnimation(which); gotoother2.startAnimation(translateAnimations[0]); gotoother3.startAnimation(translateAnimations[1]); gotoother4.startAnimation(translateAnimations[2]); gotoother5.startAnimation(translateAnimations[3]); gotoother2.setVisibility(8); gotoother3.setVisibility(8); gotoother4.setVisibility(8); gotoother5.setVisibility(8); goto_other_visiably = false; } } private TranslateAnimation[] getTranslateAnimation(int which) { TranslateAnimation[] translateAnimations = new TranslateAnimation[4]; if (which == -1) { translateAnimations[0] = new TranslateAnimation(Animation.ABSOLUTE, location[0][0] - location[1][0], Animation.RELATIVE_TO_SELF, 0f, Animation.ABSOLUTE, location[0][1] - location[1][1], Animation.RELATIVE_TO_SELF, 0f); translateAnimations[1] = new TranslateAnimation(Animation.ABSOLUTE, location[0][0] - location[2][0], Animation.RELATIVE_TO_SELF, 0f, Animation.ABSOLUTE, location[0][1] - location[2][1], Animation.RELATIVE_TO_SELF, 0f); translateAnimations[2] = new TranslateAnimation(Animation.ABSOLUTE, location[0][0] - location[3][0], Animation.RELATIVE_TO_SELF, 0f, Animation.ABSOLUTE, location[0][1] - location[3][1], Animation.RELATIVE_TO_SELF, 0f); translateAnimations[3] = new TranslateAnimation(Animation.ABSOLUTE, location[0][0] - location[4][0], Animation.RELATIVE_TO_SELF, 0f, Animation.ABSOLUTE, location[0][1] - location[4][1], Animation.RELATIVE_TO_SELF, 0f); translateAnimations[0].setDuration(100); translateAnimations[1].setDuration(150); translateAnimations[2].setDuration(200); translateAnimations[3].setDuration(250); } else { translateAnimations[0] = new TranslateAnimation( Animation.RELATIVE_TO_SELF, 0f, Animation.ABSOLUTE, location[0][0] - location[1][0], Animation.RELATIVE_TO_SELF, 0f, Animation.ABSOLUTE, location[0][1] - location[1][1]); translateAnimations[1] = new TranslateAnimation( Animation.RELATIVE_TO_SELF, 0f, Animation.ABSOLUTE, location[0][0] - location[2][0], Animation.RELATIVE_TO_SELF, 0f, Animation.ABSOLUTE, location[0][1] - location[2][1]); translateAnimations[2] = new TranslateAnimation( Animation.RELATIVE_TO_SELF, 0f, Animation.ABSOLUTE, location[0][0] - location[3][0], Animation.RELATIVE_TO_SELF, 0f, Animation.ABSOLUTE, location[0][1] - location[3][1]); translateAnimations[3] = new TranslateAnimation( Animation.RELATIVE_TO_SELF, 0f, Animation.ABSOLUTE, location[0][0] - location[4][0], Animation.RELATIVE_TO_SELF, 0f, Animation.ABSOLUTE, location[0][1] - location[4][1]); translateAnimations[0].setDuration(250); translateAnimations[1].setDuration(200); translateAnimations[2].setDuration(150); translateAnimations[3].setDuration(100); } return translateAnimations; } private ScaleAnimation[] getScaleAnimation(int which) { ScaleAnimation[] scaleAnimations = new ScaleAnimation[4]; scaleAnimations[0] = new ScaleAnimation(1, 0.1f, 1, 0.1f); scaleAnimations[1] = new ScaleAnimation(1, 0.1f, 1, 0.1f); scaleAnimations[2] = new ScaleAnimation(1, 0.1f, 1, 0.1f); scaleAnimations[3] = new ScaleAnimation(1, 0.1f, 1, 0.1f); scaleAnimations[which] = new ScaleAnimation(1, 1.7f, 1, 1.7f); scaleAnimations[0].setDuration(150); scaleAnimations[1].setDuration(150); scaleAnimations[2].setDuration(150); scaleAnimations[3].setDuration(150); return scaleAnimations; } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { Builder builder = new Builder(this); builder.setMessage("确定退出吗?"); builder.setPositiveButton("确定", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { System.exit(0); } }); builder.setNegativeButton("取消", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }); builder.show(); } return true; } } Listdata package linpeng.ztb; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.select.Elements; import android.content.Context; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.util.Log; import android.widget.Toast; public class ListData { public List<Map<String, String>> getGridviewdata() { List<Map<String, String>> list = new ArrayList<Map<String, String>>(); HashMap<String, String> hash = new HashMap<String, String>(); hash.put("grid_title", "采购公告"); list.add(hash); hash = new HashMap<String, String>(); hash.put("grid_title", "变更公告"); list.add(hash); hash = new HashMap<String, String>(); hash.put("grid_title", "答疑澄清"); list.add(hash); hash = new HashMap<String, String>(); hash.put("grid_title", "结果公示"); list.add(hash); hash = new HashMap<String, String>(); hash.put("grid_title", "单一来源"); list.add(hash); //hash = new HashMap<String, String>(); //hash.put("grid_title", "标前公示ʾ"); //list.add(hash); //hash = new HashMap<String, String>(); //hash.put("grid_title", "巢湖"); //list.add(hash); return list; } public void getListData(Document doc, int table_number, Context context, String url) { try { Element ele = doc.select("td[height=500]").first(); Elements eles = ele.select("a"); int newsclass = 0; String table_name = new IntToStrong().getname(table_number); if (ele.text().length() > 1) { DataBaseHelper dbh = new DataBaseHelper(context, table_name, null, 1); Log.i("shanchu", "ca"); dbh.dellAll(); } if (table_number != 3 && table_number != 5) { for (Element ele2 : eles) { String inittext = ele2.text(); String isend = "报名结束"; String changetext = inittext.replace("【正在报名】", "");// 替换文中的【正在报名】 String newsurl = ele2.attr("abs:href"); if (changetext.length() != inittext.length()) { isend = "正在报名"; } else { changetext = changetext.replace("【报名结束】", "");// 替换文中的【报名结束】 } if (ele2.text().replace("更多信息", "").length() >= 2) { DataBaseHelper dbh = new DataBaseHelper(context, table_name, null, 1); SQLiteDatabase sqh = dbh.getWritableDatabase(); dbh.addnewslist(newsclass, changetext, ele2.parent() .parent().select("td").last().text(), isend, newsurl); newsclass++; } } } else { for (Element ele2 : eles) { String inittext = ele2.text(); String newsurl = ele2.attr("abs:href"); String name = new IntToStrong().getname(table_number); if (ele2.text().replace("更多信息", "").length() >= 2) { DataBaseHelper dbh = new DataBaseHelper(context, name, null, 1); SQLiteDatabase sqh = dbh.getWritableDatabase(); dbh.addnewslist(newsclass, inittext, ele2.parent() .parent().select("td").last().text(), "", newsurl); newsclass++; } } } } catch (Exception e) { Log.i("s", "网络不通"); // Toast.makeText(context, "网络不通,请稍候再试",Toast.LENGTH_SHORT).show(); } } } NEWS package linpeng.ztb; import java.util.HashMap; import java.util.Map; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.select.Elements; import android.R.integer; import android.app.Activity; import android.app.AlertDialog.Builder; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.net.Uri; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.util.Log; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.view.View.OnClickListener; import android.view.Window; import android.widget.Button; import android.widget.ImageView; import android.widget.ProgressBar; import android.widget.RemoteViews.ActionException; import android.widget.TextView; import android.widget.Toast; public class News extends Activity { private TextView news_details_text, news_details_title, news_details_time; private ProgressBar news_details_progress; private int flag = 1, arg2, text_size;// flag=1表示从网络获取数据=0表示从数据库获取数据 private String kind, url; private String newsdetailstext = "", downloadtext = "", downloadaddress = "", type; private Handler handler = new Handler() { @Override public void handleMessage(Message msg) { switch (msg.arg1) { case 1: if (newsdetailstext.length() > 3) { putData(); } else { Toast.makeText(News.this, "网络不通,请稍后再试", Toast.LENGTH_SHORT) .show(); } news_details_text.setText(newsdetailstext); news_details_progress.setVisibility(8); break; } } }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.news); Intent intent = getIntent(); SharedPreferences s = getSharedPreferences("text_size", 0); text_size = s.getInt("text_size", 20); url = intent.getStringExtra("newsurl"); type = intent.getStringExtra("type"); String newstitle = intent.getStringExtra("newstitle"); String newstime = intent.getStringExtra("newstime"); news_details_text = (TextView) findViewById(R.id.news_details_text); news_details_title = (TextView) findViewById(R.id.news_details_title); news_details_time = (TextView) findViewById(R.id.news_details_time); news_details_progress = (ProgressBar) findViewById(R.id.news_details_progress); news_details_progress.setVisibility(0); news_details_title.setText(newstitle); news_details_time.setText(newstime); news_details_text.setTextSize(text_size); flag = 0; DataBaseHelper dbh = new DataBaseHelper(this, new IntToStrong().TypeToType(type), null, 1); SQLiteDatabase sql = dbh.getReadableDatabase(); Cursor cursor = sql.query(new IntToStrong().TypeToType(type), new String[] { "newsurl", "newstitle", "newstime", "newsdetails", "newsdownloadtext1", "newsdownloadurl1", "newsdownloadtext2", "newsdownloadurl2" }, "newsurl=?", new String[] { url }, null, null, null); cursor.moveToNext(); if (cursor.getCount() == 0) { new NewsThread().start(); } else { news_details_text.setText(cursor.getString(cursor .getColumnIndex("newsdetails"))); news_details_progress.setVisibility(8); } if (sql != null) { sql.close(); } } protected void putData() { DataBaseHelper dbh = new DataBaseHelper(this, new IntToStrong().TypeToType(type), null, 1); SQLiteDatabase sql = dbh.getWritableDatabase(); dbh.addetails(url, news_details_title.getText().toString(), news_details_time.getText().toString(), newsdetailstext, null, null, null, null); if (dbh != null) { dbh.close(); sql.close(); } } private void getNews() { try { String host = android.net.Proxy.getDefaultHost(); int port = android.net.Proxy.getDefaultPort(); Document doc = Jsoup.connect(url).get(); Element ele = doc.getElementById("TDContent"); int j = 1; if (ele.children().text().length() < 2) { System.out.println(1); newsdetailstext = newsdetailstext + ele.text(); } for (Element ele2 : ele.children()) { j++; newsdetailstext = newsdetailstext + ele2.text(); newsdetailstext = newsdetailstext + "\n"; newsdetailstext = newsdetailstext + "\n"; } if (j == 2) { newsdetailstext = ""; for (Element ele2 : ele.children()) { for (Element ele3 : ele2.children()) { System.out.println(3); newsdetailstext = newsdetailstext + ele3.text(); newsdetailstext = newsdetailstext + "\n"; newsdetailstext = newsdetailstext + "\n"; } } } } catch (Exception e) { e.printStackTrace(); } } private class NewsThread extends Thread { @Override public void run() { getNews(); Message msg = handler.obtainMessage(); msg.arg1 = 1; handler.sendMessage(msg); } } @Override public boolean onCreateOptionsMenu(Menu menu) { menu.add(menu.NONE, 1, 1, "字体大小"); menu.add(menu.NONE, 2, 1, "使用浏览器打开此页面"); menu.add(menu.NONE, 3, 1, "拨打此页面中电话"); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case 1: Builder builder = new Builder(this); builder.setTitle("字体大小"); builder.setSingleChoiceItems(new String[] { "大", "中", "小" }, new IntToStrong().text_size_to_order(text_size), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { if (which == 0) { news_details_text.setTextSize(24); SharedPreferences sp = getSharedPreferences( "text_size", 0); sp.edit().putInt("text_size", 24).commit(); dialog.cancel(); } else if (which == 1) { news_details_text.setTextSize(20); SharedPreferences sp = getSharedPreferences( "text_size", 0); sp.edit().putInt("text_size", 20).commit(); dialog.cancel(); } else if (which == 2) { news_details_text.setTextSize(16); SharedPreferences sp = getSharedPreferences( "text_size", 0); sp.edit().putInt("text_size", 16).commit(); dialog.cancel(); } } }); builder.setNegativeButton("取消", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }); builder.show(); break; case 2: Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(intent); break; case 3: Builder builder2=new Builder(this); Map telephone=getTelePhone(); //LayoutInflater inflater=getLayoutInflater(); //View layout=inflater.inflate(R.layout.telephone,(ViewGroup)findViewById(R.id.news_tele)); Intent intent1 = new Intent(Intent.ACTION_CALL,Uri.parse("tel:"+ telephone.get("tele"+1))); startActivity(intent1); //builder2.setView(layout); //builder2.show(); break; default: break; } return true; } private Map getTelePhone() { Map telephone = new HashMap<String, String>(); if (news_details_text.length() > 5) { int temp_index_telephone=1; String text = news_details_text.getText().toString(); for (int i = 1; i <= text.length() - 1; i++) { if (text.charAt(i) == '电' && text.charAt(i + 1) == '话' || text.charAt(i) == '电' && text.charAt(i + 2) == '话') { int k = 3; if(text.charAt(i+2)=='话'){ k=4; } String temp_telephone=""; while (text.charAt(i + k) == '1' || text.charAt(i + k) == '2' || text.charAt(i + k) == '3' || text.charAt(i + k) == '4' || text.charAt(i + k) == '5' || text.charAt(i + k) == '6' || text.charAt(i + k) == '7' || text.charAt(i + k) == '8' || text.charAt(i + k) == '9' || text.charAt(i + k) == '-' || text.charAt(i + k) == '0') { temp_telephone=temp_telephone+text.charAt(i+k); k++; } if(temp_telephone.length()>5){ temp_telephone=temp_telephone.replace("-",""); telephone.put("tele"+temp_index_telephone, temp_telephone); Log.i("sasaa", "" + temp_telephone); temp_index_telephone++; temp_telephone=""; } } } } return telephone; } }

android 为什么 onDestroy() 会在 onResume()之后执行?

从activityA跳到activityB,并且activityA执行 finish()方法,为什么在activityB的onResume结束之后,才运行activityA的onDestroy()方法?

学Python后到底能干什么?网友:我太难了

感觉全世界营销文都在推Python,但是找不到工作的话,又有哪个机构会站出来给我推荐工作? 笔者冷静分析多方数据,想跟大家说:关于超越老牌霸主Java,过去几年间Python一直都被寄予厚望。但是事实是虽然上升趋势,但是国内环境下,一时间是无法马上就超越Java的,也可以换句话说:超越Java只是时间问题罢。 太嚣张了会Python的人!找工作拿高薪这么简单? https://edu....

大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了

大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

Java校招入职华为,半年后我跑路了

何来 我,一个双非本科弟弟,有幸在 19 届的秋招中得到前东家华为(以下简称 hw)的赏识,当时秋招签订就业协议,说是入了某 java bg,之后一系列组织架构调整原因等等让人无法理解的神操作,最终毕业前夕,被通知调往其他 bg 做嵌入式开发(纯 C 语言)。 由于已至于校招末尾,之前拿到的其他 offer 又无法再收回,一时感到无力回天,只得默默接受。 毕业后,直接入职开始了嵌入式苦旅,由于从未...

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

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

@程序员:GitHub这个项目快薅羊毛

今天下午在朋友圈看到很多人都在发github的羊毛,一时没明白是怎么回事。 后来上百度搜索了一下,原来真有这回事,毕竟资源主义的羊毛不少啊,1000刀刷爆了朋友圈!不知道你们的朋友圈有没有看到类似的消息。 这到底是啥情况? 微软开发者平台GitHub 的一个区块链项目 Handshake ,搞了一个招募新会员的活动,面向GitHub 上前 25万名开发者派送 4,246.99 HNS币,大约价...

用python打开电脑摄像头,并把图像传回qq邮箱【Pyinstaller打包】

前言: 如何悄悄的打开朋友的摄像头,看看她最近过的怎么样,嘿嘿!这次让我带你们来实现这个功能。 注: 这个程序仅限在朋友之间开玩笑,别去搞什么违法的事情哦。 代码 发送邮件 使用python内置的email模块即可完成。导入相应的代码封装为一个send函数,顺便导入需要导入的包 注: 下面的代码有三处要修改的地方,两处写的qq邮箱地址,还有一处写的qq邮箱授权码,不知道qq邮箱授权码的可以去百度一...

做了5年运维,靠着这份监控知识体系,我从3K变成了40K

从来没讲过运维,因为我觉得运维这种东西不需要太多的知识面,然后我一个做了运维朋友告诉我大错特错,他就是从3K的运维一步步到40K的,甚至笑着说:我现在感觉自己什么都能做。 既然讲,就讲最重要的吧。 监控是整个运维乃至整个产品生命周期中最重要的一环,事前及时预警发现故障,事后提供详实的数据用于追查定位问题。目前业界有很多不错的开源产品可供选择。选择一款开源的监控系统,是一个省时省力、效率最高的方...

计算机网络——浅析网络层

一、前言 注意,关于ipv4和ipv6,ipv4是ip协议第4版本,也表示这个版本的ip一共4个字节,同样地,ipv6是ip协议第6版本,也表示这个版本的ip一共6个字节。 关于网络层使用路由器实现互联:在计算机网络的分层结构中,不同层有不同的中继设备: 计算机网络层 中继设备/中继系统 物理层 中继器、集线器Hub 数据链路层 网桥或交换机(交换机是多端口网桥,两者本质上是一个东西) 网络层 路...

我以为我学懂了数据结构,直到看了这个导图才发现,我错了

数据结构与算法思维导图

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

华为初面+综合面试(Java技术面)附上面试题

华为面试整体流程大致分为笔试,性格测试,面试,综合面试,回学校等结果。笔试来说,华为的难度较中等,选择题难度和网易腾讯差不多。最后的代码题,相比下来就简单很多,一共3道题目,前2题很容易就AC,题目已经记不太清楚,不过难度确实不大。最后一题最后提交的代码过了75%的样例,一直没有发现剩下的25%可能存在什么坑。 笔试部分太久远,我就不怎么回忆了。直接将面试。 面试 如果说腾讯的面试是挥金如土...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

讲一个程序员如何副业月赚三万的真实故事

loonggg读完需要3分钟速读仅需 1 分钟大家好,我是你们的校长。我之前讲过,这年头,只要肯动脑,肯行动,程序员凭借自己的技术,赚钱的方式还是有很多种的。仅仅靠在公司出卖自己的劳动时...

win10暴力查看wifi密码

刚才邻居打了个电话说:喂小灰,你家wifi的密码是多少,我怎么连不上了。 我。。。 我也忘了哎,就找到了一个好办法,分享给大家: 第一种情况:已经连接上的wifi,怎么知道密码? 打开:控制面板\网络和 Internet\网络连接 然后右击wifi连接的无线网卡,选择状态 然后像下图一样: 第二种情况:前提是我不知道啊,但是我以前知道密码。 此时可以利用dos命令了 1、利用netsh wlan...

上班一个月,后悔当初着急入职的选择了

最近有个老铁,告诉我说,上班一个月,后悔当初着急入职现在公司了。他之前在美图做手机研发,今年美图那边今年也有一波组织优化调整,他是其中一个,在协商离职后,当时捉急找工作上班,因为有房贷供着,不能没有收入来源。所以匆忙选了一家公司,实际上是一个大型外包公司,主要派遣给其他手机厂商做外包项目。**当时承诺待遇还不错,所以就立马入职去上班了。但是后面入职后,发现薪酬待遇这块并不是HR所说那样,那个HR自...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

记一次腾讯面试,我挂在了最熟悉不过的队列上……

腾讯后台面试,面试官问:如何自己实现队列?

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

2020阿里全球数学大赛:3万名高手、4道题、2天2夜未交卷

阿里巴巴全球数学竞赛( Alibaba Global Mathematics Competition)由马云发起,由中国科学技术协会、阿里巴巴基金会、阿里巴巴达摩院共同举办。大赛不设报名门槛,全世界爱好数学的人都可参与,不论是否出身数学专业、是否投身数学研究。 2020年阿里巴巴达摩院邀请北京大学、剑桥大学、浙江大学等高校的顶尖数学教师组建了出题组。中科院院士、美国艺术与科学院院士、北京国际数学...

HTTP与HTTPS的区别

面试官问HTTP与HTTPS的区别,我这样回答让他竖起大拇指!

男生更看重女生的身材脸蛋,还是思想?

往往,我们看不进去大段大段的逻辑。深刻的哲理,往往短而精悍,一阵见血。问:产品经理挺漂亮的,有点心动,但不知道合不合得来。男生更看重女生的身材脸蛋,还是...

程序员为什么千万不要瞎努力?

本文作者用对比非常鲜明的两个开发团队的故事,讲解了敏捷开发之道 —— 如果你的团队缺乏统一标准的环境,那么即使勤劳努力,不仅会极其耗时而且成果甚微,使用...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试:第十六章:Java中级开发(16k)

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

立即提问
相关内容推荐