如何改变ListView中Item的大小

标题可能表达的不是很清楚 就是一个 一个listview 或者 RecyclerView(纵向) 设置Item间距以后让点击的Item尺寸变大变宽的效果 请问这要怎么实现呢?哪种列表都可以,求一个方法!!

2个回答

点击是调用属性动画,设置item layoutparams.height

你试试吧,很简单,只是让padding变大了,然后scale变大了

public class MyListView extends ListView {

public final static float SCALE = 1.2f;
private View targetView;

public MyListView(Context context) {
    super(context);
}

public MyListView(Context context, AttributeSet attrs) {
    super(context, attrs);
}

@Override
public boolean onTouchEvent(MotionEvent ev) {
    switch (ev.getAction()){

        case MotionEvent.ACTION_DOWN:
            int XDonw = (int) ev.getX();
            int YDonw = (int) ev.getY();
            int position = pointToPosition(XDonw,YDonw);
            if(position != -1){
                targetView = getChildAt(position);
                targetView.setScaleY(SCALE);
                targetView.setScaleX(SCALE);
                targetView.setPadding(0,5,0,5);
            }

            break;
        case MotionEvent.ACTION_UP:
            if(targetView != null){
                targetView.setScaleY(1);
                targetView.setScaleX(1);
                targetView.setPadding(0,0,0,0);
            }
            break;
    }

    return super.onTouchEvent(ev);

}

}

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
Android中屏幕显示listview中的item数量
求大神告知,我如何获取当前屏幕显示出的listview的item数量呢?每个屏幕大小不一,能显示出的数量也是不一样的,有没有方法能够计算的??
改变列表视图ListView中的字体和背景
我想改变列表视图ListView中的字体(颜色和大小)和背景。我想用代码改变而不是想通过设置xml的属性实现。以下的list view看起来就像xml: <?xml version="1.0" encoding="utf-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="10dp" android:textSize="18sp" android:text="@string/hello"> 我的代码是: public class NewsActivity extends ListActivity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // ArrayAdapter listItemAdapter = new ArrayAdapter( this,android.R.layout.simple_list_item_1, v_itemList ); setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item,ynetList)); View v=getListView() ; ListView lv = getListView(); 接下来再写什么代码呢?
Android listview 随着item点击量进行排序 求大神给思路
1、listview中显示的是不同的商品,商品在本地的商品数据库中存储, 2、我在商品数据库中添加了一个字段:c_num 3、那个字段用于保存该商品的点击次数。 问题来了:我该如何根据点击次数大小进行listview的排序? 从数据库取出来的商品列表为 List<ShangPinBean> zhanShiShangPinList 。 创建的adapter为:MyAdapter myAdapter。 listview为:ListView mListView。
Android关于改变ListView里面的ImageView控件的背景图出现无法触发点击事件的问题
问题说明:我使用AudioRecord进行录音,想要点击ImageView开始录音,然后根据音量大小设置ImageView背景图 ,由于ImageView是ListView的Item里面的一个子控件,于是我开启一个线程,使Thread.sleep(100);后 notifyDataSetChanged(),这时问题就出现了,当我再次点击ImageView想要录音暂停时,发现有时候点击事件无法触发,请问大神们,这是怎么回事,在线等待中。。。。。。希望大家帮帮忙。。。。。。
Android首页轮播图 listview gridview并列
自定义listview和gridview 加载数据后底部会有空白 item之间有不同大小的空隙 还有什么思路吗
ListView中因layout_height是wrap_content而引发的问题
问题描述: 先是点击画面上的一个按钮,然后出现下方弹窗 图一:点击弹窗内的“show preview”,会出现listview,如图二 ![图一:点击弹窗内的“show preview”,会出现listview,如图二](https://img-ask.csdn.net/upload/201806/04/1528124307_944119.png) 图二:listview出现之后,快速点击任意item,按照设计应该是出现图一的画面 ![图二:listview出现之后,快速点击任意item,按照设计应该是出现图一的画面](https://img-ask.csdn.net/upload/201806/04/1528124418_35363.png) 但是实际上出现的是图三的画面, 图三:图中出现了和listview大小一样的透明层 ![图三:图中出现了和listview大小一样的透明层](https://img-ask.csdn.net/upload/201806/04/1528124620_124752.png) 这种现象只会在listview初始化的时候并且是快速点击下才会出现,往后怎么点击都不会出现。 现在怀疑这个问题可能是因为ListView中的layout_height是wrap_content而引发的问题,改成具体fill_parem或者是具体的高度就能够解决,但是要怎么证明这个现象是由这个问题导致的呢? 代码如下: ``` <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/flipper_setting" android:layout_width="fill_parent" android:layout_height="400px" android:orientation="vertical" android:gravity="center_vertical" android:background="@color/gold" > <!-- setting category page --> <LinearLayout android:id="@+id/layout1" android:layout_width="fill_parent" android:layout_height="400px" android:gravity="top" android:orientation="vertical"> <!-- Preview Setting --> <include android:id="@+id/include_setting_preview" layout="@layout/list_row_setting_category" /> </LinearLayout> <!-- detail setting page --> <LinearLayout android:layout_width="fill_parent" android:layout_height="400px" android:gravity="top" android:orientation="vertical" android:id="@+id/layout2"> <TextView android:id="@+id/text_title_detail" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center_vertical" android:textSize = "20px"/> <com.example.viewflippertest.ListViewConfig android:id="@+id/listview_detail" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@color/white" /> </LinearLayout> </LinearLayout> ``` ``` public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button button = (Button) findViewById(R.id.id_btn) ; button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Dialog dialog = createOtherSettingDialog(MainActivity.this); dialog.show(); WindowManager.LayoutParams lp = dialog.getWindow().getAttributes(); lp.width = 600; lp.height = 500; dialog.getWindow().setAttributes(lp); } }); } public static AlertDialog createOtherSettingDialog(final Context context) { //(1) LayoutInflater inflater = LayoutInflater.from(context); final View view = inflater.inflate(R.layout.dlg_setting_other, null); final ListViewConfig listView_detail = (ListViewConfig)view.findViewById(R.id.listview_detail); final TextView text_detail_title = (TextView)view.findViewById(R.id.text_title_detail); final LinearLayout layout2 = (LinearLayout) view.findViewById(R.id.layout2); final LinearLayout layout1 = (LinearLayout) view.findViewById(R.id.layout1); layout2.setVisibility(View.GONE); //(2) /*============ Preview Setting ================*/ final LinearLayout layout_preview = (LinearLayout)view.findViewById(R.id.include_setting_preview); final ArrayAdapter<String> adapter_preview = new adaper(context, R.layout.list_row_setting_detail, R.id.text_detail); final TextView text_category_preview = (TextView)layout_preview.findViewById(R.id.text_category); final TextView text_value_preview = (TextView)layout_preview.findViewById(R.id.text_value); text_category_preview.setText(context.getString(R.string.txid_scan_b_other_preview_title)); text_value_preview.setText("On"); final List<String> list_preview = new ArrayList<String>(); list_preview.add(0, "On"); list_preview.add(1, "Off"); for(int i=0; i<list_preview.size(); ++i) { adapter_preview.add(list_preview.get(i)); } layout_preview.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { System.out.println("========= layout_preview onclick"); text_detail_title.setText(R.string.txid_scan_b_other_preview_title); listView_detail.setAdapter(adapter_preview); layout1.setVisibility(View.GONE); layout2.setVisibility(View.VISIBLE); } }); /*===============================================*/ //(3) listView_detail.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { System.out.println("========= listView_detail onclick"); if(parent.getAdapter().equals(adapter_preview)) { // Update preview setting String value = adapter_preview.getItem(position); TextView text_value = (TextView)layout_preview.findViewById(R.id.text_value); text_value.setText(value); } else { /* should never reach this point */ } layout1.setVisibility(View.VISIBLE); layout2.setVisibility(View.GONE); } }); //(4) final AlertDialog.Builder dialog = new AlertDialog.Builder(context); dialog.setTitle(context.getString(R.string.txid_scan_t_top_other_title)); dialog.setNegativeButton(context.getString(R.string.txid_cmn_b_close), null); dialog.setView(view); return dialog.create(); } private static class adaper extends ArrayAdapter<String>{ public adaper(Context context, int resource, int textViewResourceId) { super(context, resource, textViewResourceId); // TODO Auto-generated constructor stub } @Override public View getView(int position, View convertView, ViewGroup parent) { System.out.println("========= position:" + position + ",convertView:" + convertView +",parent:" + parent.getMeasuredHeight() +",parent.getChildCount:" + parent.getChildCount()); return super.getView(position, convertView, parent); } } ```
为何ListView中唯独不能设置字体颜色?
[img]http://dl.iteye.com/upload/attachment/428784/4de7b93a-3dd2-3154-8ef9-2e14a84ef39b.png[/img] [code="java"] public class TradeActivity extends Activity { ListView listview; @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.mystock); String[] models=new String[]{"aaa","bbb","abc","adc","zzz","xcd"}; listview=(ListView)findViewById(R.id.listview); TradeAdapter adapter=new TradeAdapter(this,models); listview.setAdapter(adapter); } class TradeAdapter extends BaseAdapter{ Context context; String[] array; TradeAdapter(Context context,String[] array){ this.context=context; this.array=array; } @Override public int getCount() { // TODO Auto-generated method stub return array.length; } @Override public Object getItem(int position) { // TODO Auto-generated method stub return array[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 if(convertView==null){ LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView=inflater.inflate(R.layout.row_simple_list_item_2, null); } TextView textView0=(TextView)convertView.findViewById(R.id.simple_item_0); TextView textView1=(TextView)convertView.findViewById(R.id.simple_item_1); textView0.setText(array[position]); textView0.setTextColor(R.color.red);//不可以设置 textView1.setTextSize(20); textView1.setText(array[position]); textView1.setTextSize(20);//可以设置 return convertView; } } } [/code] row_simple_list_item_2.xml文件 [code="xml"] <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:id="@+id/simple_item_0" android:layout_width="100px" android:layout_height="fill_parent" android:gravity="center" android:layout_alignParentLeft="true" /> <TextView android:id="@+id/simple_item_1" android:layout_width="100px" android:layout_height="fill_parent" android:gravity="center" android:layout_toRightOf="@id/simple_item_0" /> </RelativeLayout> [/code] 很简单的一个Listview,可为什么大小可以,颜色不可以?设置了颜色的那行居然不显示文字了。
ListView需要用imageloader加载大量网络图片滑动卡顿
需求:类似QQ空间动态功能,每个Item加载头像跟图片还有一些文字。 使用的是UIL来加载图片。 问题:在滑动listview的时候会卡顿,然后加载过的图片再次出现的时候又会重新加载。并不能实现首次下载第二次的时候从内存中加载。PS:每张图片大小在20K以内、网络状态良好。 已尝试方法:优化ImageLoaderConfiguration、设置ListView.setOnScrollListener(new PauseOnScrollListener(imageLoader, true, true));、把UIL更新到最新的1.9.4。 我在网上查了很多,最多方法是给ImageView设置Tag,在加载完成时判断。if(imageUri.equals(holder.ivIcon.getTag())){ holder.ivIcon.setImageBitmap(loadedImage); } 但是我用的是imageloader.displayImage。 另外,如果给imageview加tag,然后用imageloader.loadimage()来加载图片。在onLoadingComplete()中是不能判断imageview.tag是否等于imageUri的。因为我是在adpter中,用的holder,如果要可以用,就得吧holder定义为final,然而在holder = new ViewHolder();的时候就会让holder移除holder,互相矛盾。 求大神指导。万分感谢! Adapter的getView()代码如下: @Override public View getView(int position, View convertView, ViewGroup parent) { IPetUserEvent userevent = (IPetUserEvent) getItem(position); IPetUserEventDao usereventdao=new IPetUserEventImpl(); IPetUser user=usereventdao.getUserById(userevent.getUserid()); String userName=user.getiName(); String userHeadPic=user.getiImg(); ViewHolder holder = null; if (convertView == null) { convertView = LayoutInflater.from(context).inflate(R.layout.item_userevent, null); holder = new ViewHolder(); holder.imgUserHeadPic=(ImageView) convertView.findViewById(R.id.img_item_userevent_head); holder.imgPic = (ImageView) convertView.findViewById(R.id.iv_item_userevent_eventpic); holder.tvTitle = (TextView) convertView.findViewById(R.id.tv_item_userevent_eventname); holder.tvTime = (TextView) convertView.findViewById(R.id.tv_item_userevent_eventtime); holder.tvUserName=(TextView) convertView.findViewById(R.id.tv_item_userevent_username); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } holder.tvTitle.setText(userevent.getEventname()); holder.tvTime.setText("活动时间:"+userevent.getEventtime()); holder.tvUserName.setText(userName); String url= HttpUtil.BASE_URL+"uploadfile/userevent/"+userevent.getEventpic(); String url1= HttpUtil.BASE_URL+"uploadfile/userImage/"+userHeadPic; imageLoader.displayImage(url1, holder.imgUserHeadPic, options, animateFirstListener); imageLoader.displayImage(url, holder.imgPic, options, animateFirstListener);// return convertView; }
listview 如何删除sdcard卡文件并刷新界面?红色部分
package com.genny; import java.io.File; import android.app.Activity; import android.app.AlertDialog; import android.content.ContentResolver; import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; import android.database.Cursor; import android.graphics.Color; import android.net.Uri; import android.os.Bundle; import android.os.Environment; import android.provider.MediaStore; import android.view.ContextMenu; import android.view.Gravity; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ContextMenu.ContextMenuInfo; import android.view.ViewGroup.LayoutParams; import android.widget.AdapterView; import android.widget.CursorAdapter; import android.widget.LinearLayout; import android.widget.ListView; import android.widget.RelativeLayout; import android.widget.SimpleAdapter; import android.widget.SimpleCursorAdapter; import android.widget.TextView; import android.widget.Toast; import android.widget.AdapterView.*; public class MusicListActivity extends Activity{ private ListView listview; private Cursor c = null; private File file = null; private CursorAdapter adapter; private ScanSdReceiver scanSdReceiver = null; private String[] _title = null; private String[] _name = null; private String[] _size; private String[] _path = null; private String[] _singer = null; private String[] _album = null; private int[] _time; private int index; //menu菜单 private static final int ITEM1 = Menu.FIRST; private static final int ITEM2 = Menu.FIRST + 1; private static final int ITEM3 = Menu.FIRST + 2; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.musiclist); listview = (ListView)findViewById(android.R.id.list); c = this.getContentResolver() .query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, new String[]{MediaStore.Audio.Media.TITLE,//歌曲名0 MediaStore.Audio.Media.DURATION,//时长1 MediaStore.Audio.Media.ARTIST,//歌手2 MediaStore.Audio.Media._ID,//ID3 MediaStore.Audio.Media.DISPLAY_NAME,//文件名4 MediaStore.Audio.Media.ALBUM,//专辑5 MediaStore.Audio.Media.SIZE,//大小6 MediaStore.Audio.Media.DATA},//路径7 null, null, null); /* if (c==null || c.getCount()==0){ builder = new AlertDialog.Builder(this); builder.setMessage("存储列表为空...").setPositiveButton("确定", null); ad = builder.create(); ad.show(); }*/ c.moveToFirst(); _title = new String[c.getCount()]; _name = new String[c.getCount()]; _path = new String[c.getCount()]; _singer = new String[c.getCount()]; _album = new String[c.getCount()]; _size = new String[c.getCount()]; _time = new int[c.getCount()]; for(int i=0;i<c.getCount();i++){ _title[i] = c.getString(0); _name[i] = c.getString(4); _path[i] = c.getString(7); _singer[i] = c.getString(2); _album[i] = c.getString(5); _size[i] = c.getString(6); _time[i] = c.getInt(1); c.moveToNext(); } adapter = new SimpleCursorAdapter(this, R.layout.listitem, c, new String[]{MediaStore.Audio.AudioColumns.TITLE, MediaStore.Audio.AudioColumns.ARTIST}, new int[]{R.id.music, R.id.songer}); listview.setAdapter(adapter); listview.setOnItemClickListener(new ListItemClickListener()); registerForContextMenu(listview); } class ListItemClickListener implements OnItemClickListener{ @Override public void onItemClick(AdapterView<?> arg0, View view, int position, long id) { // TODO Auto-generated method stub Intent i = new Intent(MusicPlayerService.MUSIC_CONTROL); i.putExtra("cmd", MusicPlayerService.CMD_JUMP); i.putExtra("pos", position); sendBroadcast(i); finish(); } } @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { // TODO Auto-generated method stub index = ((AdapterContextMenuInfo)menuInfo).position;//获取menu点击项的position menu.setHeaderIcon(R.drawable.header_icon); menu.setHeaderTitle(_title[index]); menu.add(0,ITEM1,0,"播放"); menu.add(0,ITEM2,0,"删除"); menu.add(0,ITEM3,0,"详细"); super.onCreateContextMenu(menu, v, menuInfo); } public boolean onContextItemSelected(MenuItem item){ switch(item.getItemId()){ case ITEM1: Intent i = new Intent(MusicPlayerService.MUSIC_CONTROL); i.putExtra("cmd", MusicPlayerService.CMD_JUMP); i.putExtra("pos", index); sendBroadcast(i); finish(); break; [color=red]case ITEM2: /*下面的代码能够删除listview中的音频文件,但是删除之后如何刷新呢?*/ file = new File(_path[index]); if(file.exists()){ file.delete(); } break;[/color] case ITEM3: Intent intent = new Intent(MusicListActivity.this,MusicInfo.class); intent.putExtra("_Name", _name[index]); intent.putExtra("_Size", _size[index]); intent.putExtra("_Singer", _singer[index]); intent.putExtra("_Album", _album[index]); intent.putExtra("_Time", _time[index]); intent.putExtra("_Path", _path[index]); startActivity(intent); System.out.println("Name:"+_name[index]+" Size:"+_size[index]+" Path:"+_path[index]+" Singer:"+_singer[index]+" Album:"+_album[index]+" Time:"+_time[index]); break; default: break; } return super.onContextItemSelected(item); } //添加menu菜单 public boolean onCreateOptionsMenu(Menu menu){ super.onCreateOptionsMenu(menu); menu.add(0,ITEM1,0,"更新列表").setIcon(R.drawable.update_file); menu.add(0,ITEM2,0,"返回").setIcon(R.drawable.menu_exit); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()){ case ITEM1: scanSdCard(); break; case ITEM2: onBackPressed(); break; default: break; } return true; } //扫描本地sdcard卡文件 private void scanSdCard(){ IntentFilter intentfilter = new IntentFilter(Intent.ACTION_MEDIA_SCANNER_STARTED); intentfilter.addAction(Intent.ACTION_MEDIA_SCANNER_FINISHED); intentfilter.addDataScheme("file"); scanSdReceiver = new ScanSdReceiver(); registerReceiver(scanSdReceiver, intentfilter); sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED,Uri.parse("file://"+Environment.getExternalStorageDirectory().getAbsolutePath()))); } @Override public void onBackPressed() { // TODO Auto-generated method stub if (scanSdReceiver!=null) unregisterReceiver(scanSdReceiver); this.finish(); super.onBackPressed(); } }
android viewpage动态加载同一个布局轮播
根据网络获取数据的不同大小动态向viewpage加载同一个布局页面,就像listview的Item布局那样, 有textview image ,怎么实现啊? 我的代码: for(int i=0;i<list.size();i++){ View v=lf.inflate(R.layout.doctor_item, null); viewListView.add(v); } 传给pageadapter 然后在instantiateItem中赋值 Textview v=viewList.get(position).findviewbyId(R.id.name_tv); v.setText("姓名") Textview a=viewList.get(position).findviewbyId(R.id.name_tv); a.setText("年龄") 这样可是最后结果 却不正确。 添加了两页 结果只有第一页显示数据。第二页是空的 求大神 帮忙实现
PyQt5的QListView多选返回值
代码如下,怎么样实现多选返回列表,显示在QLabel ![图片说明](https://img-ask.csdn.net/upload/201812/03/1543834681_373537.gif) ``` import sys from PyQt5.QtWidgets import QApplication,QWidget,QVBoxLayout,QListView,QAbstractItemView from PyQt5.QtCore import QStringListModel from PyQt5 import QtWidgets class ListViewDemo(QWidget): def __init__(self,parent=None): super(ListViewDemo, self).__init__(parent) #设置初始大小与标题 self.resize(300,270) self.setWindowTitle('QListView 多选问题') #垂直布局 self.layout=QVBoxLayout() #实例化列表视图 self.listview=QListView() #实例化列表模型,添加数据 self.slm=QStringListModel() self.qList=['Item 1','Item 2','Item 3','Item 4','Item 5','Item 6','Item 7','Item 8','Item 9'] #设置模型列表视图,加载数据列表 self.slm.setStringList(self.qList) #设置列表视图的模型 self.listview.setModel(self.slm) # 多选 self.listview.setSelectionMode(QAbstractItemView.ExtendedSelection) # 不能对表格进行修改(双击重命名等) self.listview.setEditTriggers(QAbstractItemView.NoEditTriggers) self.label_dqxz = QtWidgets.QLabel() self.label_dqxz.setText("当前选择:-") #单击触发自定义的槽函数 self.listview.clicked.connect(self.clicked) #设置窗口布局,加载控件 self.layout.addWidget(self.listview) self.layout.addWidget(self.label_dqxz) self.setLayout(self.layout) def clicked(self,index): self.label_dqxz.setText('当前选择:'+self.qList[index.row()]) if __name__ == '__main__': app=QApplication(sys.argv) win=ListViewDemo() win.show() sys.exit(app.exec_()) ```
java.lang.IllegalStateException:
03-23 15:07:45.899: E/AndroidRuntime(12482): java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first. public class AppManagerActivity extends Activity implements OnClickListener { private List<AppInfo> mAppInfoList; private ListView lv_app_list; private MyAdapter mAdapter; private ArrayList<AppInfo> mSystemList; private ArrayList<AppInfo> mCustomerList; private TextView tv_des; private AppInfo mAppInfo; private Handler mHandler =new Handler(){ public void handleMessage(android.os.Message msg){ mAdapter = new MyAdapter(); lv_app_list.setAdapter(mAdapter); if (tv_des!=null&&mCustomerList!=null) { tv_des.setText("用户应用("+mCustomerList.size()+")"); } }; }; class MyAdapter extends BaseAdapter{ //获取适配器中条目类型的总数(改成两种,纯文字,文件+图片) @Override public int getViewTypeCount(){ return super.getViewTypeCount()+1; } //指定索引指向条目的类型,条目类型状态码指定(0(复用),1) @Override public int getItemViewType(int position){ if (position==0||position==mCustomerList.size()+1) { //返回0,代表纯文本条目的状态码 return 0; } else { //返回1,代表文本+图片条目的状态码 return 1; } } @Override public int getCount() { //listView中增加两个描述项目 return mSystemList.size()+mCustomerList.size()+2; } @Override public AppInfo getItem(int position) { if (position==0||position==mCustomerList.size()+1) { return null; }else { if (position<mCustomerList.size()+1) { return mCustomerList.get(position-1); }else { //返回应用对应条目的对象 return mSystemList.get(position-mCustomerList.size()-2); } } } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { int type = getItemViewType(position); if (type==0) { //展示纯文本灰色条目 ViewTitleHolder holder=null; if (convertView==null) { convertView=View.inflate(getApplicationContext(),R.layout.listview_app_item_title,null); holder=new ViewTitleHolder(); holder.tv_title=(TextView)convertView.findViewById(R.id.tv_title); convertView.setTag(holder); }else { holder=(ViewTitleHolder)convertView.getTag(); } if (position==0) { holder.tv_title.setText("用户应用("+mCustomerList.size()+")"); }else { holder.tv_title.setText("系统应用("+mSystemList.size()+")"); } return convertView; }else { //展示文本加图片条目 ViewHolder holder=null; if (convertView==null) { convertView=View.inflate(getApplicationContext(),R.layout.listview_app_item,null); holder=new ViewHolder(); holder.iv_icon=(ImageView)convertView.findViewById(R.id.iv_icon); holder.tv_name=(TextView)convertView.findViewById(R.id.tv_name); holder.tv_path=(TextView)convertView.findViewById(R.id.tv_path); convertView.setTag(holder); }else { holder=(ViewHolder)convertView.getTag(); } holder.iv_icon.setBackgroundDrawable(getItem(position).icon); holder.tv_name.setText(getItem(position).name); if (getItem(position).isSdCard) { holder.tv_path.setText("sd卡应用"); }else { holder.tv_path.setText("手机应用"); } return convertView; } } } static class ViewHolder{ ImageView iv_icon; TextView tv_name; TextView tv_path; } static class ViewTitleHolder{ TextView tv_title; } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_app_manager); initTitle(); initList(); } private void initList() { tv_des = (TextView)findViewById(R.id.tv_des); lv_app_list = (ListView)findViewById(R.id.lv_app_list); new Thread(){ public void run(){ mAppInfoList = AppInfoProvider.getAppInfoList(getApplicationContext()); mSystemList = new ArrayList<AppInfo>(); mCustomerList = new ArrayList<AppInfo>(); for (AppInfo appInfo : mAppInfoList) { if (appInfo.isSystem) { //系统应用 mSystemList.add(appInfo); }else { //非系统应用 mCustomerList.add(appInfo); } } mHandler.sendEmptyMessage(0); }; }.start(); lv_app_list.setOnScrollListener(new OnScrollListener(){ @Override public void onScrollStateChanged(AbsListView view, int scrollState) { // TODO Auto-generated method stub } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { //滚动过程中调用方法 //AbsListView中view就是listView对象 //firstVisibleItem第一个可见条目索引值 //visibleItemCount当前一个屏幕的可见条目数 //总共条目总数 if (mCustomerList!=null&&mSystemList!=null) { if (firstVisibleItem>=mCustomerList.size()+1) { //滚动到了系统应用 tv_des.setText("系统应用("+mSystemList.size()+")"); }else { //滚动到了用户条目 tv_des.setText("用户应用("+mCustomerList.size()+")"); } } } }); lv_app_list.setOnItemClickListener(new OnItemClickListener(){ //view点中条目指向view的对象 @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // TODO Auto-generated method stub if (position==0||position==mCustomerList.size()+1) { return; }else { if (position<mCustomerList.size()+1) { mAppInfo = mCustomerList.get(position-1); }else { //返回应用对应条目的对象 mAppInfo=mSystemList.get(position-mCustomerList.size()-2); } showPopupWindow(view); } } }); } protected void showPopupWindow(View view) { View popupView = View.inflate(this,R.layout.popupwindow_layout,null); TextView tv_uninstall =(TextView)popupView.findViewById(R.id.tv_uninstall); TextView tv_start=(TextView)popupView.findViewById(R.id.tv_start); TextView tv_share=(TextView)popupView.findViewById(R.id.tv_share); tv_uninstall.setOnClickListener(this); tv_start.setOnClickListener(this); tv_share.setOnClickListener(this); //1,创建窗体对象,指定宽高 PopupWindow popupWindow = new PopupWindow(view, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT,true); //2,设置一个透明背景,如果不设置,回退按钮没反应 popupWindow.setBackgroundDrawable(new ColorDrawable()); //3,指定窗体位置 popupWindow.showAsDropDown(view,50,-view.getHeight()); } /** * */ private void initTitle() { //1,获取磁盘(区分于运存)可用大小,磁盘路径 String path = Environment.getDataDirectory().getAbsolutePath(); //2,获取sd卡可用大小,sd卡路径 String sdPath = Environment.getExternalStorageDirectory().getAbsolutePath(); //3,获取以上两个路径下文件夹的可用大小 String memoryAvailSpace= Formatter.formatFileSize(this,getAvailSpace(path)); String sdMemoryAvailSpace = Formatter.formatFileSize(this,getAvailSpace(sdPath)); TextView tv_memory = (TextView) findViewById(R.id.tv_memory); TextView tv_sd_memory = (TextView) findViewById(R.id.tv_sd_memory); tv_memory.setText("磁盘可用:"+memoryAvailSpace); tv_sd_memory.setText("sd卡可用:"+sdMemoryAvailSpace); } private long getAvailSpace(String path) { //statFs获取可用磁盘大小的一个类 StatFs statFs = new StatFs(path); //获取可用区块的个数 long count = statFs.getAvailableBlocks(); //获取区块的大小 long size = statFs.getBlockSize(); //区块大小*可用区块个数=可用空间大小 return count*size; } @Override public void onClick(View v) { // TODO Auto-generated method stub } }
代码有错误,求大神帮忙指点迷津!!!!
public class ChatFragment extends BaseFragment implements OnClickListener,ReceiveMsgListener{ // private NetThreadHelper netThreadHelper; // private ImageView chat_item_head; //头像 private TextView chat_name; //名字及IP private TextView chat_mood; //组名 private Button chat_quit; //退出按钮 private ListView chat_list; //聊天列表 private EditText chat_input; //聊天输入框 private Button chat_send; //发送按钮 private List<ChatMessage> msgList; //用于显示的消息list private String receiverName; //要接收本activity所发送的消息的用户名字 private String receiverIp; //要接收本activity所发送的消息的用户IP private String receiverGroup; //要接收本activity所发送的消息的用户组名 private ChatListAdapter adapter; //ListView对应的adapter private String selfName; private String selfGroup; private final static int MENU_ITEM_SENDFILE = Menu.FIRST; //发送文件 private final static int MENU_ITEM_EXIT = Menu.FIRST + 1; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View chatLayout = inflater.inflate(R.layout.chat, container, false); return chatLayout; // findViews(); // netThreadHelper = NetThreadHelper.newInstance(); msgList = new ArrayList<ChatMessage>(); Intent intent = getIntent(); Bundle bundle = intent.getExtras(); receiverName = bundle.getString("receiverName"); receiverIp = bundle.getString("receiverIp"); receiverGroup = bundle.getString("receiverGroup"); selfName = "android飞鸽"; selfGroup = "android"; chat_name.setText(receiverName + "(" + receiverIp + ")"); chat_mood.setText("组名:" + receiverGroup); chat_quit.setOnClickListener(this); chat_send.setOnClickListener(this); Iterator<ChatMessage> it = netThreadHelper.getReceiveMsgQueue().iterator(); while(it.hasNext()){ //循环消息队列,获取队列中与本聊天activity相关信息 ChatMessage temp = it.next(); //若消息队列中的发送者与本activity的消息接收者IP相同,则将这个消息拿出,添加到本activity要显示的消息list中 if(receiverIp.equals(temp.getSenderIp())){ msgList.add(temp); //添加到显示list it.remove(); //将本消息从消息队列中移除 } } adapter = new ChatListAdapter(getActivity(), msgList); chat_list.setAdapter(adapter); netThreadHelper.addReceiveMsgListener(this); //注册到listeners } public void onViewCreated(View view, Bundle savedInstanceState) { // TODO Auto-generated method stub super.onViewCreated(view, savedInstanceState); chat_name = (TextView)view.findViewById(R.id.chat_name); chat_mood = (TextView) view.findViewById(R.id.chat_mood); chat_quit = (Button) view.findViewById(R.id.chat_quit); chat_list = (ListView) view.findViewById(R.id.chat_list); chat_input = (EditText) view.findViewById(R.id.chat_input); chat_send = (Button) view.findViewById(R.id.chat_send); } @Override public void processMessage(Message msg) { // TODO Auto-generated method stub switch(msg.what){ case IpMessageConst.IPMSG_SENDMSG: adapter.notifyDataSetChanged(); //刷新ListView break; case IpMessageConst.IPMSG_RELEASEFILES:{ //拒绝接受文件,停止发送文件线程 if(NetTcpFileSendThread.server != null){ try { NetTcpFileSendThread.server.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } break; case UsedConst.FILESENDSUCCESS:{ //文件发送成功 makeTextShort("文件发送成功"); } break; } //end of switch } @Override public boolean receive(ChatMessage msg) { // TODO Auto-generated method stub if(receiverIp.equals(msg.getSenderIp())){ //若消息与本activity有关,则接收 msgList.add(msg); //将此消息添加到显示list中 sendEmptyMessage(IpMessageConst.IPMSG_SENDMSG); //使用handle通知,来更新UI BaseFragment.playMsg(); return true; } return false; } @Override public void finish() { // TODO Auto-generated method stub //一定要移除,不然信息接收会出现问题 netThreadHelper.removeReceiveMsgListener(this); super.finish(); } @Override public void onClick(View v) { // TODO Auto-generated method stub if(v == chat_send){ sendAndAddMessage(); }else if(v == chat_quit){ finish(); } } /** * 发送消息并将该消息添加到UI显示 */ private void sendAndAddMessage(){ String msgStr = chat_input.getText().toString().trim(); if(!"".equals(msgStr)){ //发送消息 IpMessageProtocol sendMsg = new IpMessageProtocol(); sendMsg.setVersion(String.valueOf(IpMessageConst.VERSION)); sendMsg.setSenderName(selfName); sendMsg.setSenderHost(selfGroup); sendMsg.setCommandNo(IpMessageConst.IPMSG_SENDMSG); sendMsg.setAdditionalSection(msgStr); InetAddress sendto = null; try { sendto = InetAddress.getByName(receiverIp); } catch (UnknownHostException e) { // TODO Auto-generated catch block Log.e("MyFeiGeChatActivity", "发送地址有误"); } if(sendto != null) netThreadHelper.sendUdpData(sendMsg.getProtocolString() + "\0", sendto, IpMessageConst.PORT); //添加消息到显示list ChatMessage selfMsg = new ChatMessage("localhost", selfName, msgStr, new Date()); selfMsg.setSelfMsg(true); //设置为自身消息 msgList.add(selfMsg); }else{ makeTextShort("不能发送空内容"); } chat_input.setText(""); adapter.notifyDataSetChanged();//更新UI } @Override public boolean onCreateOptionsMenu(Menu menu) { // TODO Auto-generated method stub super.onCreateOptionsMenu(menu); menu.add(0, MENU_ITEM_SENDFILE, 0, "发送文件"); menu.add(0, MENU_ITEM_EXIT, 0, "退出"); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // TODO Auto-generated method stub switch(item.getItemId()){ case MENU_ITEM_SENDFILE: Intent intent = new Intent(getActivity(), FileFragment.class); startActivityForResult(intent, 0); break; case MENU_ITEM_EXIT: finish(); break; } return super.onOptionsItemSelected(item); } @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { // TODO Auto-generated method stub super.onActivityResult(requestCode, resultCode, data); if(resultCode == RESULT_OK){ //得到发送文件的路径 Bundle bundle = data.getExtras(); String filePaths = bundle.getString("filePaths"); //附加文件信息串,多个文件使用"\0"进行分隔 // Toast.makeText(this, filePaths, Toast.LENGTH_SHORT).show(); String[] filePathArray = filePaths.split("\0"); //发送传送文件UDP数据报 IpMessageProtocol sendPro = new IpMessageProtocol(); sendPro.setVersion("" +IpMessageConst.VERSION); sendPro.setCommandNo(IpMessageConst.IPMSG_SENDMSG | IpMessageConst.IPMSG_FILEATTACHOPT); sendPro.setSenderName(selfName); sendPro.setSenderHost(selfGroup); String msgStr = ""; //发送的消息 StringBuffer additionInfoSb = new StringBuffer(); //用于组合附加文件格式的sb for(String path:filePathArray){ File file = new File(path); additionInfoSb.append("0:"); additionInfoSb.append(file.getName() + ":"); additionInfoSb.append(Long.toHexString(file.length()) + ":"); //文件大小十六进制表示 additionInfoSb.append(Long.toHexString(file.lastModified()) + ":"); //文件创建时间,现在暂时已最后修改时间替代 additionInfoSb.append(IpMessageConst.IPMSG_FILE_REGULAR + ":"); byte[] bt = {0x07}; //用于分隔多个发送文件的字符 String splitStr = new String(bt); additionInfoSb.append(splitStr); } sendPro.setAdditionalSection(msgStr + "\0" + additionInfoSb.toString() + "\0"); InetAddress sendto = null; try { sendto = InetAddress.getByName(receiverIp); } catch (UnknownHostException e) { // TODO Auto-generated catch block Log.e("MyFeiGeChatActivity", "发送地址有误"); } if(sendto != null) netThreadHelper.sendUdpData(sendPro.getProtocolString(), sendto, IpMessageConst.PORT); //监听2425端口,准备接受TCP连接请求 Thread netTcpFileSendThread = new Thread(new NetTcpFileSendThread(filePathArray)); netTcpFileSendThread.start(); //启动线程 } } } ![![![图片说明](https://img-ask.csdn.net/upload/201605/12/1463064059_713861.png)图片说明](https://img-ask.csdn.net/upload/201605/12/1463063989_240367.png)图片说明](https://img-ask.csdn.net/upload/201605/12/1463063930_306003.png) 求大神指点
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; } }
在中国程序员是青春饭吗?
今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...
我在支付宝花了1分钟,查到了女朋友的开房记录!
在大数据时代下,不管你做什么都会留下蛛丝马迹,只要学会把各种软件运用到极致,捉奸简直轻而易举。今天就来给大家分享一下,什么叫大数据抓出轨。据史料证明,马爸爸年轻时曾被...
程序员请照顾好自己,周末病魔差点一套带走我。
程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。
卸载 x 雷某度!GitHub 标星 1.5w+,从此我只用这款全能高速下载工具!
作者 | Rocky0429 来源 | Python空间 大家好,我是 Rocky0429,一个喜欢在网上收集各种资源的蒟蒻… 网上资源眼花缭乱,下载的方式也同样千奇百怪,比如 BT 下载,磁力链接,网盘资源等等等等,下个资源可真不容易,不一样的方式要用不同的下载软件,因此某比较有名的 x 雷和某度网盘成了我经常使用的工具。 作为一个没有钱的穷鬼,某度网盘几十 kb 的下载速度让我...
20道你必须要背会的微服务面试题,面试一定会被问到
写在前面: 在学习springcloud之前大家一定要先了解下,常见的面试题有那块,然后我们带着问题去学习这个微服务技术,那么就会更加理解springcloud技术。如果你已经学了springcloud,那么在准备面试的时候,一定要看看看这些面试题。 文章目录1、什么是微服务?2、微服务之间是如何通讯的?3、springcloud 与dubbo有哪些区别?4、请谈谈对SpringBoot 和S...
为什么猝死的都是程序员,基本上不见产品经理猝死呢?
相信大家时不时听到程序员猝死的消息,但是基本上听不到产品经理猝死的消息,这是为什么呢? 我们先百度搜一下:程序员猝死,出现将近700多万条搜索结果: 搜索一下:产品经理猝死,只有400万条的搜索结果,从搜索结果数量上来看,程序员猝死的搜索结果就比产品经理猝死的搜索结果高了一倍,而且从下图可以看到,首页里面的五条搜索结果,其实只有两条才是符合条件。 所以程序员猝死的概率真的比产品经理大,并不是错...
毕业5年,我问遍了身边的大佬,总结了他们的学习方法
我问了身边10个大佬,总结了他们的学习方法,原来成功都是有迹可循的。
推荐10个堪称神器的学习网站
每天都会收到很多读者的私信,问我:“二哥,有什么推荐的学习网站吗?最近很浮躁,手头的一些网站都看烦了,想看看二哥这里有什么新鲜货。” 今天一早做了个恶梦,梦到被老板辞退了。虽然说在我们公司,只有我辞退老板的份,没有老板辞退我这一说,但是还是被吓得 4 点多都起来了。(主要是因为我掌握着公司所有的核心源码,哈哈哈) 既然 4 点多起来,就得好好利用起来。于是我就挑选了 10 个堪称神器的学习网站,推...
这些软件太强了,Windows必装!尤其程序员!
Windows可谓是大多数人的生产力工具,集娱乐办公于一体,虽然在程序员这个群体中都说苹果是信仰,但是大部分不都是从Windows过来的,而且现在依然有很多的程序员用Windows。 所以,今天我就把我私藏的Windows必装的软件分享给大家,如果有一个你没有用过甚至没有听过,那你就赚了????,这可都是提升你幸福感的高效率生产力工具哦! 走起!???? NO、1 ScreenToGif 屏幕,摄像头和白板...
阿里面试,面试官没想到一个ArrayList,我都能跟他扯半小时
我是真的没想到,面试官会这样问我ArrayList。
曾经优秀的人,怎么就突然不优秀了。
职场上有很多辛酸事,很多合伙人出局的故事,很多技术骨干被裁员的故事。说来模板都类似,曾经是名校毕业,曾经是优秀员工,曾经被领导表扬,曾经业绩突出,然而突然有一天,因为种种原因,被裁员了,...
大学四年因为知道了这32个网站,我成了别人眼中的大神!
依稀记得,毕业那天,我们导员发给我毕业证的时候对我说“你可是咱们系的风云人物啊”,哎呀,别提当时多开心啦????,嗯,我们导员是所有导员中最帅的一个,真的???? 不过,导员说的是实话,很多人都叫我大神的,为啥,因为我知道这32个网站啊,你说强不强????,这次是绝对的干货,看好啦,走起来! PS:每个网站都是学计算机混互联网必须知道的,真的牛杯,我就不过多介绍了,大家自行探索,觉得没用的,尽管留言吐槽吧???? 社...
良心推荐,我珍藏的一些Chrome插件
上次搬家的时候,发了一个朋友圈,附带的照片中不小心暴露了自己的 Chrome 浏览器插件之多,于是就有小伙伴评论说分享一下我觉得还不错的浏览器插件。 我下面就把我日常工作和学习中经常用到的一些 Chrome 浏览器插件分享给大家,随便一个都能提高你的“生活品质”和工作效率。 Markdown Here Markdown Here 可以让你更愉快的写邮件,由于支持 Markdown 直接转电子邮...
看完这篇HTTP,跟面试官扯皮就没问题了
我是一名程序员,我的主要编程语言是 Java,我更是一名 Web 开发人员,所以我必须要了解 HTTP,所以本篇文章就来带你从 HTTP 入门到进阶,看完让你有一种恍然大悟、醍醐灌顶的感觉。 最初在有网络之前,我们的电脑都是单机的,单机系统是孤立的,我还记得 05 年前那会儿家里有个电脑,想打电脑游戏还得两个人在一个电脑上玩儿,及其不方便。我就想为什么家里人不让上网,我的同学 xxx 家里有网,每...
2020 年,大火的 Python 和 JavaScript 是否会被取而代之?
Python 和 JavaScript 是目前最火的两大编程语言,但是2020 年,什么编程语言将会取而代之呢? 作者 |Richard Kenneth Eng 译者 |明明如月,责编 | 郭芮 出品 | CSDN(ID:CSDNnews) 以下为译文: Python 和 JavaScript 是目前最火的两大编程语言。然而,他们不可能永远屹立不倒。最终,必将像其他编程语言一...
史上最全的IDEA快捷键总结
现在Idea成了主流开发工具,这篇博客对其使用的快捷键做了总结,希望对大家的开发工作有所帮助。
阿里程序员写了一个新手都写不出的低级bug,被骂惨了。
这种新手都不会范的错,居然被一个工作好几年的小伙子写出来,差点被当场开除了。
谁是华为扫地僧?
是的,华为也有扫地僧!2020年2月11-12日,“养在深闺人不知”的华为2012实验室扫地僧们,将在华为开发者大会2020(Cloud)上,和大家见面。到时,你可以和扫地僧们,吃一个洋...
AI 没让人类失业,搞 AI 的人先失业了
最近和几个 AI 领域的大佬闲聊 根据他们讲的消息和段子 改编出下面这个故事 如有雷同 都是巧合 1. 老王创业失败,被限制高消费 “这里写我跑路的消息实在太夸张了。” 王葱葱哼笑一下,把消息分享给群里。 阿杰也看了消息,笑了笑。在座几位也都笑了。 王葱葱是个有名的人物,21岁那年以全额奖学金进入 KMU 攻读人工智能博士,累计发表论文 40 余篇,个人技术博客更是成为深度学习领域内风向标。 ...
2020年,冯唐49岁:我给20、30岁IT职场年轻人的建议
点击“技术领导力”关注∆每天早上8:30推送 作者|Mr.K 编辑| Emma 来源|技术领导力(ID:jishulingdaoli) 前天的推文《冯唐:职场人35岁以后,方法论比经验重要》,收到了不少读者的反馈,觉得挺受启发。其实,冯唐写了不少关于职场方面的文章,都挺不错的。可惜大家只记住了“春风十里不如你”、“如何避免成为油腻腻的中年人”等不那么正经的文章。 本文整理了冯...
最全最强!世界大学计算机专业排名总结!
我正在参与CSDN200进20,希望得到您的支持,扫码续投票5次。感谢您! (为表示感谢,您投票后私信我,我把我总结的人工智能手推笔记和思维导图发送给您,感谢!) 目录 泰晤士高等教育世界大学排名 QS 世界大学排名 US News 世界大学排名 世界大学学术排名(Academic Ranking of World Universities) 泰晤士高等教育世界大学排名 中国共...
作为一名大学生,如何在B站上快乐的学习?
B站是个宝,谁用谁知道???? 作为一名大学生,你必须掌握的一项能力就是自学能力,很多看起来很牛X的人,你可以了解下,人家私底下一定是花大量的时间自学的,你可能会说,我也想学习啊,可是嘞,该学习啥嘞,不怕告诉你,互联网时代,最不缺的就是学习资源,最宝贵的是啥? 你可能会说是时间,不,不是时间,而是你的注意力,懂了吧! 那么,你说学习资源多,我咋不知道,那今天我就告诉你一个你必须知道的学习的地方,人称...
那些年,我们信了课本里的那些鬼话
教材永远都是有错误的,从小学到大学,我们不断的学习了很多错误知识。 斑羚飞渡 在我们学习的很多小学课文里,有很多是错误文章,或者说是假课文。像《斑羚飞渡》: 随着镰刀头羊的那声吼叫,整个斑羚群迅速分成两拨,老年斑羚为一拨,年轻斑羚为一拨。 就在这时,我看见,从那拨老斑羚里走出一只公斑羚来。公斑羚朝那拨年轻斑羚示意性地咩了一声,一只半大的斑羚应声走了出来。一老一少走到伤心崖,后退了几步,突...
使用 Python 和百度语音识别生成视频字幕
文章目录从视频中提取音频根据静音对音频分段使用百度语音识别获取 Access Token使用 Raw 数据进行合成生成字幕总结 从视频中提取音频 安装 moviepy pip install moviepy 相关代码: audio_file = work_path + '\\out.wav' video = VideoFileClip(video_file) video.audio.write_...
一个程序在计算机中是如何运行的?超级干货!!!
强烈声明:本文很干,请自备茶水!???? 开门见山,咱不说废话! 你有没有想过,你写的程序,是如何在计算机中运行的吗?比如我们搞Java的,肯定写过这段代码 public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } ...
【蘑菇街技术部年会】程序员与女神共舞,鼻血再次没止住。(文末内推)
蘑菇街技术部的年会,别开生面,一样全是美女。
那个在阿里养猪的工程师,5年了……
简介: 在阿里,走过1825天,没有趴下,依旧斗志满满,被称为“五年陈”。他们会被授予一枚戒指,过程就叫做“授戒仪式”。今天,咱们听听阿里的那些“五年陈”们的故事。 下一个五年,猪圈见! 我就是那个在养猪场里敲代码的工程师,一年多前我和20位工程师去了四川的猪场,出发前总架构师慷慨激昂的说:同学们,中国的养猪产业将因为我们而改变。但到了猪场,发现根本不是那么回事:要个WIFI,没有;...
为什么程序猿都不愿意去外包?
分享外包的组织架构,盈利模式,亲身经历,以及根据一些外包朋友的反馈,写了这篇文章 ,希望对正在找工作的老铁有所帮助
Java校招入职华为,半年后我跑路了
何来 我,一个双非本科弟弟,有幸在 19 届的秋招中得到前东家华为(以下简称 hw)的赏识,当时秋招签订就业协议,说是入了某 java bg,之后一系列组织架构调整原因等等让人无法理解的神操作,最终毕业前夕,被通知调往其他 bg 做嵌入式开发(纯 C 语言)。 由于已至于校招末尾,之前拿到的其他 offer 又无法再收回,一时感到无力回天,只得默默接受。 毕业后,直接入职开始了嵌入式苦旅,由于从未...
世界上有哪些代码量很少,但很牛逼很经典的算法或项目案例?
点击上方蓝字设为星标下面开始今天的学习~今天分享四个代码量很少,但很牛逼很经典的算法或项目案例。1、no code 项目地址:https://github.com/kelseyhight...
Python全栈 Linux基础之3.Linux常用命令
Linux对文件(包括目录)有很多常用命令,可以加快开发效率:ls是列出当前目录下的文件列表,选项有-a、-l、-h,还可以使用通配符;c功能是跳转目录,可以使用相对路径和绝对路径;mkdir命令创建一个新的目录,有-p选项,rm删除文件或目录,有-f、-r选项;cp用于复制文件,有-i、-r选项,tree命令可以将目录结构显示出来(树状显示),有-d选项,mv用来移动文件/目录,有-i选项;cat查看文件内容,more分屏显示文件内容,grep搜索内容;>、>>将执行结果重定向到一个文件;|用于管道输出。
​两年前不知如何编写代码的我,现在是一名人工智能工程师
全文共3526字,预计学习时长11分钟 图源:Unsplash 经常有小伙伴私信给小芯,我没有编程基础,不会写代码,如何进入AI行业呢?还能赶上AI浪潮吗? 任何时候努力都不算晚。 下面,小芯就给大家讲一个朋友的真实故事,希望能给那些处于迷茫与徘徊中的小伙伴们一丝启发。(下文以第一人称叙述) 图源:Unsplash 正如Elsa所说,职业转换是...
强烈推荐10本程序员必读的书
很遗憾,这个春节注定是刻骨铭心的,新型冠状病毒让每个人的神经都是紧绷的。那些处在武汉的白衣天使们,尤其值得我们的尊敬。而我们这些窝在家里的程序员,能不外出就不外出,就是对社会做出的最大的贡献。 有些读者私下问我,窝了几天,有点颓丧,能否推荐几本书在家里看看。我花了一天的时间,挑选了 10 本我最喜欢的书,你可以挑选感兴趣的来读一读。读书不仅可以平复恐惧的压力,还可以对未来充满希望,毕竟苦难终将会...
Python实战:抓肺炎疫情实时数据,画2019-nCoV疫情地图
今天,群里白垩老师问如何用python画武汉肺炎疫情地图。白垩老师是研究海洋生态与地球生物的学者,国家重点实验室成员,于不惑之年学习python,实为我等学习楷模。先前我并没有关注武汉肺炎的具体数据,也没有画过类似的数据分布图。于是就拿了两个小时,专门研究了一下,遂成此文。
非典逼出了淘宝和京东,新冠病毒能够逼出什么?
loonggg读完需要5分钟速读仅需 2 分钟大家好,我是你们的校长。我知道大家在家里都憋坏了,大家可能相对于封闭在家里“坐月子”,更希望能够早日上班。今天我带着大家换个思路来聊一个问题...
立即提问