安卓ListView的item里的imageview如何显示服务器图片

各位大佬好,请问ListView里的ImageView怎么显示服务器的图片?能拿到的数据只有图片的URL

9个回答

现在图片框架有很多比如说Glide,Glide.with(context) .load("图片地址").into(imageview);在你的build.gradle中compile 'com.github.bumptech.glide:glide:3.7.0'

可以通过URL拿下来,然后改怎么放就怎么放进去

现在很多网络框架中都有图片下载的方法,直接调用,在adpater中每完成一个item,开始现在图片,因为下载图片是一部线程,不要担心listview会卡顿

还有一个地方需要注意的就是,下载的图片是不规则的,需要对图片进行裁剪,按比例显示等等问题

根据url去请求图片到你的项目中

fresco glide imag-loader 一般的图片加载框架都可以啊

网络框架这么多,随便找一个就可以了。

用glide吧 就是一楼的方案 比较假单 容易上手

建议使用第三方的图片加载框架。

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

Android:listView的Item中有一个ImageView,问题是上传图片到服务器,然后从服务器中取数据显示的时候,有的图片旋转了90度,但是在点击预览的时候,图片是正常的。哪位大神可以帮帮忙???指点一下

android客户端从服务器获取图片报数组下标越界

速求:各位大神好,帮忙给看一下,刚才运行安卓客户端从服务器获取图片报“数组下标越界”,程序挂掉了,啥原因呢:public class MainActivity extends Activity implements OnScrollListener { private static final String TAG = null; private int count=0; public SimpleAdapter simpleAdapter; ListView listview; int lastItemIndex; private int times = 1;// 表示第几次刷新,从而从数据库中调出不同的数据 public static List<HashMap<String, Object>> list = new ArrayList<HashMap<String, Object>>(); View moreView; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); listview = (ListView) findViewById(R.id.listview); // Button button = (Button) findViewById(R.id.button_main); moreView = getLayoutInflater().inflate(R.layout.load, null); // 点击listview的某一项而进入 listview.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent intent = new Intent(MainActivity.this, DetailActivity.class); intent.putExtra("id",position); startActivity(intent); } }); // 向上滑动获取更新,这个更适合一般的常见的操作方式 count = list.size(); String[] items = { "img", "title", "list_item" }; int[] ids = { R.id.list_item, R.id.list_name, R.id.list_detail }; simpleAdapter = new SimpleAdapter(this, getData(times), R.layout.activity_list, items, ids); listview.addFooterView(moreView); listview.setAdapter(simpleAdapter); // 这段代码是现实自定义位图所必需的,较为简单,直接放上即可 simpleAdapter.setViewBinder(new ViewBinder() { public boolean setViewValue(View view, Object data, String textRepresentation) { if (view instanceof ImageView && data instanceof Drawable) { ImageView iv = (ImageView) view; iv.setImageDrawable((Drawable) data); return true; } else return false; } }); // 滑动获取更新,这个更适合一般的常见的操作方法,this是因为集成了相应的接口可以直接这样写,然后必须有其全部实现 listview.setOnScrollListener(this); } // 从服务器获取数据并将要现实的数据封装成List List<HashMap<String, Object>> getData(int num) { times=times+1; List<NameValuePair> lists = new ArrayList<NameValuePair>(); // 使得请求格式较为统一 lists.add(new BasicNameValuePair("id", num + "")); // 网络请求 Thread httpThread = new Thread(new HttpUtil(HttpUtil.httpUrl + "show", lists)); httpThread.start(); // 直到新线程出栈,主线程运行 try { httpThread.join(); } catch (InterruptedException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } String result = HttpUtil.result; String[] results = result.split(";"); for (int i = 0; i < results.length; i++) { HashMap<String, Object> map = new HashMap<String, Object>(); String[] item = results[i].split(","); String name = item[2]; String price = item[1]; String pic = item[0]; String tag = "item"; Log.v(tag, item[0]); FormatTools format = new FormatTools(); map.put("img", format.Bytes2Drawable(Base64.decode(pic, Base64.DEFAULT))); map.put("title", name); map.put("list_item", price); list.add(map); } count=list.size(); return list; } //滑动到底部 @Override public void onScrollStateChanged(AbsListView view, int scrollState) { if (lastItemIndex == simpleAdapter.getCount()-1 && scrollState == this.SCROLL_STATE_IDLE&&lastItemIndex<25) { Log.i(TAG, "拉到最底部"); moreView.setVisibility(view.VISIBLE); mHandler.sendEmptyMessage(0); } if(lastItemIndex>=25){ Toast.makeText(getApplicationContext(), "没有更多了", Toast.LENGTH_SHORT).show(); listview.removeFooterView(moreView); } } //滑动监视器 @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { lastItemIndex = firstVisibleItem + visibleItemCount - 1 -1; } // Handler用于处理UI交互 private Handler mHandler = new Handler() { public void handleMessage(android.os.Message msg) { switch (msg.what) { case 0: getData(times); // 向服务器请求数据 //直接用这个即可以更新里adapter和listview simpleAdapter.notifyDataSetChanged(); moreView.setVisibility(View.GONE); break; case 1: break; default: break; } }; }; }

求大神帮助,使用Bmob服务器,获取数据解析数据???我还使用异步加载

//我建立了Bean,里面有一个ImageView,两个TextView, //ImageView id=imgView; //TextView id=tittle; //TextView id=content; //BaseAdapter在最下面列出来; //ListView布局是activity_main; //item布局是item_layout; 我都是按照视频写的,基础差,请见谅 ``` package com.bmoblist; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.List; import org.json.JSONArray; import org.json.JSONObject; import org.json.JSONStringer; import android.app.Activity; import android.os.AsyncTask; import android.os.Bundle; import android.widget.BaseAdapter; import android.widget.ListAdapter; import android.widget.ListView; import android.widget.Toast; import cn.bmob.v3.Bmob; import cn.bmob.v3.BmobQuery; import cn.bmob.v3.listener.FindListener; import cn.volley.toolbox.JsonObjectRequest; public class MainActivity extends Activity { private ListView listView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // 初始化 Bmob SDK // 使用时请将第二个参数Application ID替换成你在Bmob服务器端创建的Application ID Bmob.initialize(this, "这里是就不透露了"); ZhinengBean zhinengBean = new ZhinengBean(); ListView listView = (ListView)findViewById(R.layout.activity_main); } //这一步完全不知道怎么弄 private List<ZhinengBean> getJsonData(){ //bmobString不知道写啥 List<ZhinengBean> zhinengBeanList = new ArrayList<>(); String jsonString = readStream(ZhinengBean.openStream()); return null; } private String readStream(InputStream is){ InputStreamReader isr; String result = ""; try { String line =""; isr = new InputStreamReader(is,"utf-8"); BufferedReader br = new BufferedReader(isr); while ((line=br.readLine()) != null){ result += line; } } catch (UnsupportedEncodingException e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } catch (IOException e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } return result; } class NewsAsyncTask extends AsyncTask<String,Void,List<ZhinengBean>>{ @Override protected List<ZhinengBean> doInBackground(String... params) { // TODO 自动生成的方法存根 return getJsonData(params[0]); //不知道怎么写 } } } ``` ``` package com.bmoblist; import java.util.List; import android.content.Context; import android.media.Image; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.TextView; public class MyAdapter extends BaseAdapter { //通过构造方法,将数据源和适配器绑定在一起》》》》 private List<ZhinengBean> mList; private LayoutInflater mInflater; public MyAdapter (Context context,List<ZhinengBean> list){ mList = list; mInflater = LayoutInflater.from(context); } //》》》》》》》 //表示显示多少条数据 @Override public int getCount() { // TODO 自动生成的方法存根 return mList.size(); } @Override public Object getItem(int position) { // TODO 自动生成的方法存根 return mList.get(position); } @Override public long getItemId(int position) { // TODO 自动生成的方法存根 return position; } @Override public View getView(int position, View converView, ViewGroup parent) { // TODO 自动生成的方法存根 ViewHolder viewHolder; if(converView == null){ viewHolder = new ViewHolder(); converView = mInflater.inflate(R.layout.iten_layout,null); viewHolder.znImage = (ImageView) converView.findViewById(R.id.tv_icon); viewHolder.znTittle = (TextView) converView.findViewById(R.id.tv_tittle); viewHolder.znTittle2 = (TextView) converView.findViewById(R.id.tv_content); converView.setTag(viewHolder); }else{ viewHolder = (ViewHolder) converView.getTag(); } viewHolder.znImage.setImageResource(R.id.tv_icon); viewHolder.znTittle.setText(mList.get(position).getZntittle()); viewHolder.znTittle2.setText(mList.get(position).getZntittle2()); return converView; } class ViewHolder { public ImageView znImage; public TextView znTittle; public TextView znTittle2; } } ```

新手请教ListView 刷新问题

这是显示ListView的界面 package com.security.phonepolice.view; import java.util.ArrayList; import java.util.List; import org.apache.http.Header; import org.json.JSONException; import org.json.JSONObject; import com.loopj.android.http.AsyncHttpResponseHandler; import com.loopj.android.http.RequestParams; import com.security.phonepolice.ContantValues; import com.security.phonepolice.R; import com.security.phonepolice.entity.Msgbean; import com.security.phonepolice.http.MyHttpclient; import com.security.phonepolice.util.SharedPreferenceUtil; import com.security.phonepolice.view.MessageManager.NotificationAdapter; import com.security.phonepolice.view.OAFileFragment.FileViewHolder; import com.security.phonepolice.view.widget.MyListView; import com.security.phonepolice.view.widget.MyListView.RefreshListener; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.support.v4.app.Fragment; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; public class OANotifyFragment extends Fragment implements OnClickListener, OnItemClickListener{ private View view; private ImageView mPreIv; private MyListView mNotifyLv; private LayoutInflater mInflater; private NotifyAdapter adapter = null; private TextView notifyUpload; private List<Msgbean> mList; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { view = inflater.inflate(R.layout.oa_notify_ui, container, false); mInflater = inflater; init(); initEvent(); return view; } private void init() { mNotifyLv = (MyListView) view.findViewById(R.id.oa_notify_lv); } private void initEvent() { mList = new ArrayList<Msgbean>(); adapter = new NotifyAdapter(mList); mNotifyLv.setOnItemClickListener(this); mNotifyLv.setAdapter(adapter); mNotifyLv.setOnRefreshListener(new RefreshListener() { @Override public Object refreshing() { RequestParams params = new RequestParams(); params.put("action", "Message"); String serverAdd = SharedPreferenceUtil.getServerStringSP(getActivity(), "config", "serverAdd"); MyHttpclient.post(serverAdd+ContantValues.IDCARD_URL, params, new AsyncHttpResponseHandler(){ @Override public void onSuccess( int statusCode, Header[] headers, String content) { super.onSuccess(statusCode, headers, content); if (!content.equals("failed")) { Msgbean msgBean = new Msgbean(); try { JSONObject jsonObject=new JSONObject(content); msgBean.setTitle(jsonObject.getString("TITLE")); msgBean.setContent(jsonObject.getString("CONTENT")); Log.i("-----------", jsonObject.getString("TITLE")); List<Msgbean> list = new ArrayList<Msgbean>(); list.add(msgBean); mList = list; adapter.notifyDataSetChanged(); } catch (JSONException e) { e.printStackTrace(); } }else { Toast.makeText(getActivity(), "刷新失败", Toast.LENGTH_LONG).show(); } } @Override public void onFailure( Throwable error, String content) { Toast.makeText(getActivity(), "连接失败", Toast.LENGTH_LONG).show(); super.onFailure(error, content); } } ); return null; } @Override public void refreshed(Object obj) { Toast.makeText(getActivity(), "刷新完毕", Toast.LENGTH_LONG).show(); } @Override public void more() { Toast.makeText(getActivity(), "正在加载", Toast.LENGTH_LONG).show(); } }); } class NotifyAdapter extends BaseAdapter{ private List<Msgbean> list; public NotifyAdapter(List<Msgbean> list) { this.list = list; } @Override public int getCount() { return list.size(); } @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 0; } @Override public View getView(int position, View convertView, ViewGroup parent) { NotifyViewHolder viewHolder = null; if (convertView == null) { convertView = mInflater.inflate(R.layout.oa_item, null); viewHolder = new NotifyViewHolder(); viewHolder.itemIv = (ImageView) convertView.findViewById(R.id.oa_item_iv); viewHolder.itemTitle = (TextView) convertView.findViewById(R.id.oa_item_title); viewHolder.itemContent = (TextView) convertView.findViewById(R.id.oa_item_content); convertView.setTag(viewHolder); }else { viewHolder = (NotifyViewHolder) convertView.getTag(); } viewHolder.itemIv.setImageResource(R.drawable.notification_small); viewHolder.itemTitle.setText(list.get(position).getTitle()); viewHolder.itemContent.setText(list.get(position).getContent()); return convertView; } } public static class NotifyViewHolder{ public ImageView itemIv; public TextView itemTitle; public TextView itemContent; } @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent intent = null; if (position > 0) { //去服务器拉取警情的详细信息 intent = new Intent(); intent.putExtra("InfoTag", "OANotify"); intent.setClass(getActivity(), MessageDetail.class); startActivity(intent); } } } 这是在网上找到的自定义的ListView package com.security.phonepolice.view.widget; import java.text.SimpleDateFormat; import java.util.Date; import com.security.phonepolice.R; import android.content.Context; import android.os.Handler; import android.os.Message; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.AbsListView; import android.widget.AbsListView.OnScrollListener; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ListAdapter; import android.widget.ListView; import android.widget.ProgressBar; import android.widget.TextView; /** * 下拉刷新,底部更多 * */ public class MyListView extends ListView implements OnScrollListener{ private float mDownY; private float mMoveY; private int mHeaderHeight; private int mCurrentScrollState; private final static int NONE_PULL_REFRESH = 0; //正常状态 private final static int ENTER_PULL_REFRESH = 1; //进入下拉刷新状态 private final static int OVER_PULL_REFRESH = 2; //进入松手刷新状态 private final static int EXIT_PULL_REFRESH = 3; //松手后反弹和加载状态 private int mPullRefreshState = 0; //记录刷新状态 private final static int REFRESH_BACKING = 0; //反弹中 private final static int REFRESH_BACED = 1; //达到刷新界限,反弹结束后 private final static int REFRESH_RETURN = 2; //没有达到刷新界限,返回 private final static int REFRESH_DONE = 3; //加载数据结束 private LinearLayout mHeaderLinearLayout = null; private LinearLayout mFooterLinearLayout = null; private TextView mHeaderTextView = null; private TextView mHeaderUpdateText = null; private ImageView mHeaderPullDownImageView = null; private ImageView mHeaderReleaseDownImageView = null; private ProgressBar mHeaderProgressBar = null; private TextView mFooterTextView = null; private ProgressBar mFooterProgressBar = null; private SimpleDateFormat mSimpleDateFormat; private Object mRefreshObject = null; private RefreshListener mRefreshListener = null; public void setOnRefreshListener(RefreshListener refreshListener) { this.mRefreshListener = refreshListener; } public MyListView(Context context) { this(context, null); } public MyListView(Context context, AttributeSet attrs) { super(context, attrs); init(context); } void init(final Context context) { mHeaderLinearLayout = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.refresh_list_header, null); addHeaderView(mHeaderLinearLayout); mHeaderTextView = (TextView) findViewById(R.id.refresh_list_header_text); mHeaderUpdateText = (TextView) findViewById(R.id.refresh_list_header_last_update); mHeaderPullDownImageView = (ImageView) findViewById(R.id.refresh_list_header_pull_down); mHeaderReleaseDownImageView = (ImageView) findViewById(R.id.refresh_list_header_release_up); mHeaderProgressBar = (ProgressBar) findViewById(R.id.refresh_list_header_progressbar); mFooterLinearLayout = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.refresh_list_footer, null); addFooterView(mFooterLinearLayout); mFooterProgressBar = (ProgressBar) findViewById(R.id.refresh_list_footer_progressbar); mFooterTextView = (TextView) mFooterLinearLayout.findViewById(R.id.refresh_list_footer_text); mFooterLinearLayout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if ("加载更多".equals(mFooterTextView.getText())) { mFooterTextView.setText("正在加载"); mFooterProgressBar.setVisibility(View.VISIBLE); if (mRefreshListener != null) { mRefreshListener.more(); } } } }); setSelection(1); setOnScrollListener(this); measureView(mHeaderLinearLayout); mHeaderHeight = mHeaderLinearLayout.getMeasuredHeight(); mSimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm"); mHeaderUpdateText.setText("下拉刷新"+ mSimpleDateFormat.format(new Date())); } @Override public boolean onTouchEvent(MotionEvent ev) { switch (ev.getAction()) { case MotionEvent.ACTION_DOWN: mDownY = ev.getY(); break; case MotionEvent.ACTION_MOVE: mMoveY = ev.getY(); if (mPullRefreshState == OVER_PULL_REFRESH) { mHeaderLinearLayout.setPadding(mHeaderLinearLayout.getPaddingLeft(), (int)((mMoveY - mDownY)/3), mHeaderLinearLayout.getPaddingRight(), mHeaderLinearLayout.getPaddingBottom()); } break; case MotionEvent.ACTION_UP: //when you action up, it will do these: //1. roll back util header topPadding is 0 //2. hide the header by setSelection(1) if (mPullRefreshState == OVER_PULL_REFRESH || mPullRefreshState == ENTER_PULL_REFRESH) { new Thread() { public void run() { Message msg; while(mHeaderLinearLayout.getPaddingTop() > 1) { msg = mHandler.obtainMessage(); msg.what = REFRESH_BACKING; mHandler.sendMessage(msg); try { sleep(5); } catch (InterruptedException e) { e.printStackTrace(); } } msg = mHandler.obtainMessage(); if (mPullRefreshState == OVER_PULL_REFRESH) { msg.what = REFRESH_BACED; } else { msg.what = REFRESH_RETURN; } mHandler.sendMessage(msg); }; }.start(); } break; } return super.onTouchEvent(ev); } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (mCurrentScrollState == SCROLL_STATE_TOUCH_SCROLL && firstVisibleItem == 0 && (mHeaderLinearLayout.getBottom() >= 0 && mHeaderLinearLayout.getBottom() < mHeaderHeight)) { //进入且仅进入下拉刷新状态 if (mPullRefreshState == NONE_PULL_REFRESH) { mPullRefreshState = ENTER_PULL_REFRESH; } } else if (mCurrentScrollState == SCROLL_STATE_TOUCH_SCROLL && firstVisibleItem == 0 && (mHeaderLinearLayout.getBottom() >= mHeaderHeight)) { //下拉达到界限,进入松手刷新状态 if (mPullRefreshState == ENTER_PULL_REFRESH || mPullRefreshState == NONE_PULL_REFRESH) { mPullRefreshState = OVER_PULL_REFRESH; mDownY = mMoveY; //为下拉1/3折扣效果记录开始位置 mHeaderTextView.setText("松手刷新");//显示松手刷新 mHeaderPullDownImageView.setVisibility(View.GONE);//隐藏"下拉刷新" mHeaderReleaseDownImageView.setVisibility(View.VISIBLE);//显示向上的箭头 } } else if (mCurrentScrollState == SCROLL_STATE_TOUCH_SCROLL && firstVisibleItem != 0) { //不刷新了 if (mPullRefreshState == ENTER_PULL_REFRESH) { mPullRefreshState = NONE_PULL_REFRESH; } } else if (mCurrentScrollState == SCROLL_STATE_FLING && firstVisibleItem == 0) { //飞滑状态,不能显示出header,也不能影响正常的飞滑 //只在正常情况下才纠正位置 if (mPullRefreshState == NONE_PULL_REFRESH) { setSelection(1); } } } @Override public void onScrollStateChanged(AbsListView view, int scrollState) { mCurrentScrollState = scrollState; } @Override public void setAdapter(ListAdapter adapter) { super.setAdapter(adapter); setSelection(1); } private void measureView(View child) { ViewGroup.LayoutParams p = child.getLayoutParams(); if (p == null) { p = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); } int childWidthSpec = ViewGroup.getChildMeasureSpec(0, 0 + 0, p.width); int lpHeight = p.height; int childHeightSpec; if (lpHeight > 0) { childHeightSpec = MeasureSpec.makeMeasureSpec(lpHeight, MeasureSpec.EXACTLY); } else { childHeightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); } child.measure(childWidthSpec, childHeightSpec); } private Handler mHandler = new Handler(){ @Override public void handleMessage(Message msg) { switch (msg.what) { case REFRESH_BACKING: mHeaderLinearLayout.setPadding(mHeaderLinearLayout.getPaddingLeft(), (int) (mHeaderLinearLayout.getPaddingTop()*0.75f), mHeaderLinearLayout.getPaddingRight(), mHeaderLinearLayout.getPaddingBottom()); break; case REFRESH_BACED: mHeaderTextView.setText("正在加载..."); mHeaderProgressBar.setVisibility(View.VISIBLE); mHeaderPullDownImageView.setVisibility(View.GONE); mHeaderReleaseDownImageView.setVisibility(View.GONE); mPullRefreshState = EXIT_PULL_REFRESH; new Thread() { public void run() { if (mRefreshListener != null) { mRefreshObject = mRefreshListener.refreshing(); } Message msg = mHandler.obtainMessage(); msg.what = REFRESH_DONE; mHandler.sendMessage(msg); }; }.start(); break; case REFRESH_RETURN: mHeaderTextView.setText("下拉刷新"); mHeaderProgressBar.setVisibility(View.INVISIBLE); mHeaderPullDownImageView.setVisibility(View.VISIBLE); mHeaderReleaseDownImageView.setVisibility(View.GONE); mHeaderLinearLayout.setPadding(mHeaderLinearLayout.getPaddingLeft(), 0, mHeaderLinearLayout.getPaddingRight(), mHeaderLinearLayout.getPaddingBottom()); mPullRefreshState = NONE_PULL_REFRESH; setSelection(1); break; case REFRESH_DONE: mHeaderTextView.setText("下拉刷新"); mHeaderProgressBar.setVisibility(View.INVISIBLE); mHeaderPullDownImageView.setVisibility(View.VISIBLE); mHeaderReleaseDownImageView.setVisibility(View.GONE); mHeaderUpdateText.setText("最新更新"+ mSimpleDateFormat.format(new Date())); mHeaderLinearLayout.setPadding(mHeaderLinearLayout.getPaddingLeft(), 0, mHeaderLinearLayout.getPaddingRight(), mHeaderLinearLayout.getPaddingBottom()); mPullRefreshState = NONE_PULL_REFRESH; setSelection(1); if (mRefreshListener != null) { mRefreshListener.refreshed(mRefreshObject); } break; default: break; } } }; public interface RefreshListener { Object refreshing(); void refreshed(Object obj); void more(); } public void finishFootView() { mFooterProgressBar.setVisibility(View.GONE); mFooterTextView.setText("更多"); } public void addFootView() { if (getFooterViewsCount() == 0) { addFooterView(mFooterLinearLayout); } } public void removeFootView() { removeFooterView(mFooterLinearLayout); } } 这是实体类: package com.security.phonepolice.entity; public class Msgbean { private int id; private String title; private String content; private String relName; private String relTime; public int getId() { return id; } public void setId(int id) { this.id = id; } 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; } public String getRelName() { return relName; } public void setRelName(String relName) { this.relName = relName; } public String getRelTime() { return relTime; } public void setRelTime(String relTime) { this.relTime = relTime; } } 走到这一步法mNotifyLv.setOnRefreshListener(new RefreshListener() 就停了 为什么刷新的时候就是不走接口中的refreshing()方法。求大神指教啊!

关于ListView 刷新的问题

package com.box.page; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.android.volley.RequestQueue; import com.android.volley.Request.Method; import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.StringRequest; import com.android.volley.toolbox.Volley; import com.box.datamodel.CartGood; import com.box.sjfood_v_1_0.MainActivity; import com.box.sjfood_v_1_0.R; import com.box.tools.UrlString; import android.content.Intent; import android.content.SharedPreferences; import android.graphics.LinearGradient; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.Button; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ListView; import android.widget.RelativeLayout; import android.widget.TextView; public class ShoppingCart extends Fragment{ private boolean hasitem = false;//进入界面时,接受服务器数据,表示购物车内是否有物品 private Button goForBuybutton;//去逛逛 private Button calculate;//结算按钮 private RequestQueue mQueue = null; private boolean isLogin;//是否已经登陆 private String phoneString;//用户手机号 private SharedPreferences sp; private Handler mHandler; private ArrayList<CartGood> cartGoods; private RelativeLayout shopping_somethingLayout; private LinearLayout shopping_nothingLayout; private ListView listView;//购物车listview private Button allSelectImageView;//全选图标 private TextView totalPriceTextView;//总价 private ShoppingCartAdapter myAdapter; private float totalPrice = 0;//记录总价 private ArrayList<Boolean> isselected = new ArrayList<Boolean>(); public View onCreateView( final LayoutInflater inflater, @Nullable final ViewGroup container, @Nullable Bundle savedInstanceState) { // TODO Auto-generated method stub //获取用户信息 getUserInfo(); View view = inflater.inflate(R.layout.shoppingcart, container,false); //获取页面 initView(view); //获取用户的订单信息 mQueue = Volley.newRequestQueue(getActivity()); GetOrderList(); mHandler = new Handler() { @Override public void handleMessage(Message msg) { // TODO Auto-generated method stub if(msg.obj.toString().equals("-1")) { isLogin = false; hasitem = false; Log.i("isLogin1", String.valueOf(isLogin)); Log.i("hasitem1", String.valueOf(hasitem)); setAllGone(); shopping_nothingLayout.setVisibility(View.VISIBLE); } else { JSONObject jsonObject= new JSONObject(); jsonObject = (JSONObject) msg.obj; cartGoods = (ArrayList<CartGood>) JSONArray.parseArray(jsonObject.getJSONArray("orderList").toString(), CartGood.class); isLogin = true; hasitem = true; Log.i("isLogin1", String.valueOf(isLogin)); Log.i("hasitem1", String.valueOf(hasitem)); setAllGone(); shopping_somethingLayout.setVisibility(View.VISIBLE); dataToListView(); } } /* * 把cartgoods中的数据传到适配器中 */ private void dataToListView() { // TODO Auto-generated method stub for(int i = 0;i<cartGoods.size();i++) { Log.i("cartGoods",cartGoods.get(i).getName()+ i); isselected.add(false); } myAdapter = new ShoppingCartAdapter(getActivity(), cartGoods,isselected); listView.setAdapter(myAdapter); myAdapter.notifyDataSetChanged(); } private void setAllGone() { // TODO Auto-generated method stub shopping_somethingLayout.setVisibility(View.GONE); shopping_nothingLayout.setVisibility(View.GONE); } }; return view; } private void initView(View view) { // TODO Auto-generated method stub shopping_nothingLayout = (LinearLayout) view.findViewById(R.id.shoppingcart_nothing_layout); shopping_somethingLayout = (RelativeLayout) view.findViewById(R.id.shoppingcart_something_layout); initNothingView(view); initSomethingView(view); } //初始化有item时的界面 private void initSomethingView(View view) { // TODO Auto-generated method stub calculate = (Button) view.findViewById (R.id.shoppingcart_something_calcu);//结算按钮 allSelectImageView = (Button) view.findViewById (R.id.shoppingcart_allselect);//全选 totalPriceTextView = (TextView)view.findViewById (R.id.shoppingcart_totalprice);//总价 listView = (ListView)view.findViewById(R.id.shoppingcart_listview); allSelectImageView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub isselected.add(true); if (allSelectImageView.isSelected()) { for(int i = 0;i<isselected.size();i++) { isselected.set(i, false); } allSelectImageView.setSelected(false); } else { for(int i = 0;i<isselected.size();i++) { isselected.set(i, true); } allSelectImageView.setSelected(true); } CalculatePrice(); myAdapter.notifyDataSetChanged(); } }); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // TODO Auto-generated method stub final int mposition = position; final CartGood cartGood = cartGoods.get(position); final Button button = (Button) view.findViewById(R.id.shoppingcart_item_select); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub if (isselected.get(mposition)) { allSelectImageView.setSelected(false); } isselected.set(mposition, !isselected.get(mposition)); Log.i("isselected", String.valueOf(isselected.get(mposition))); //Log.i("isselectedadapter",String.valueOf(myAdapter.getList().get(mposition))); myAdapter.notifyDataSetChanged(); CalculatePrice(); } }); } }); } /* * 获取用户存储在手机上的ID * 若未登录则Id置为-1,另外处理 */ private void CalculatePrice() { // TODO Auto-generated method stub totalPrice = 0; for(int i = 0;i<isselected.size();i++) { if(isselected.get(i)) { if(cartGoods.get(i).getIsDiscount() == 1) totalPrice = totalPrice+cartGoods.get(i).getDiscountPrice(); else { totalPrice = totalPrice + cartGoods.get(i).getPrice(); } } } totalPriceTextView.setText("¥ "+String.valueOf(totalPrice)); } private void getUserInfo() { // TODO Auto-generated method stub sp = getActivity().getSharedPreferences("login", 0); isLogin = sp.getBoolean("Login", false); phoneString = sp.getString("phone", "-1"); if(!isLogin) { hasitem = false; phoneString = "-1"; } } /* * 获取用户订单信息 */ private void GetOrderList() { // TODO Auto-generated method stub StringRequest stringRequest = new StringRequest(Method.POST, UrlString.GetOrderString, new Response.Listener<String>() { @Override public void onResponse(String response) { // TODO Auto-generated method stub Log.i("用户订单信息", response); JSONObject jsonObject =JSONObject.parseObject(response); String statusString = jsonObject.getString("status"); if(statusString.equals("success")) { Message message = mHandler.obtainMessage(); if(!jsonObject.getString("message").equals("获取购物车订单成功")) { message.obj = -1; } else { message.obj = jsonObject; } mHandler.sendMessage(message); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { // TODO Auto-generated method stub } }) { protected Map<String, String> getParams(){ Map<String, String> params = new HashMap<String, String>(); params.put("phoneId", phoneString); return params; } }; mQueue.add(stringRequest); } private void initNothingView(View view) { // TODO Auto-generated method stub goForBuybutton = (Button)view.findViewById(R.id.shoppingcart_goforbuy); goForBuybutton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Intent intent = new Intent(getActivity(),MainActivity.class); startActivity(intent); getActivity().finish(); } }); } } ``` ``` 为什么listview不会自动刷新? 是不是只要adapter绑定的数据源发生变化了,调用notifydatasetonchanged就会刷新? notifydatasetonchanged()调用有什么条件?

Android通过webservice向oracle存储读取图片

最近老大让我们做一个向数据库上传读取图片的功能,我使用oracle服务器,通过调用webservice,我已经实现图片保存到手手机本地,可以把存到手机的图片路径上传,但是图片上传依然没解决,可是纠结了好久还是不知道入何上传读取,(菜鸟一枚,希望得到详细指导,最好有demo 下面是客户端部分代码//跳转到拍照功能 private void picture(){ imageView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { startActivityForResult(new Intent(AddActivity.this, PicCutActivity.class), 100); } }); } //获得图片地址显示 protected void onActivityResult(int requestCode, int resultCode, Intent data) { // TODO Auto-generated method stub if (resultCode == 100) { result = data.getExtras().getString("result"); Log.i("TAG",result+"result"); custumeruils.setPhoto_path(result); imageView.setImageBitmap(BitmapFactory.decodeFile(result)); } super.onActivityResult(requestCode, resultCode, data); } public void setAdapter(){ ArrayAdapter<emp> adapter= new ArrayAdapter<emp>(this, android.R.layout.simple_list_item_1,use ); //adapter.notifyDataSetChanged(); listView.setAdapter(adapter); } private void setListener() { adduserButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { new Thread(){ public void run() { id=Integer.parseInt(useridEdit.getText().toString()); username=usernameEdit.getText().toString().trim(); address=useraddressEdit.getText().toString().trim(); insertUser(); }; }.start(); } }); } private List<emp> parseArray(JSONArray ary) throws JSONException { List<emp> emps=new ArrayList<emp>(); for(int i=0; i<ary.length(); i++){ JSONObject empObj=ary.getJSONObject(i); emp emps1=new emp(empObj.getInt("useid"), empObj.getString("name"), empObj.getString("address") ); emps.add(emps1); } Log.i("TAG",emps.toString()); return emps; } public String insertUser() { SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); request.addProperty("id", id); request.addProperty("username", username); request.addProperty("hobby", address); //传送图片路径 request.addProperty("result",result); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope.bodyOut = request; // envelope.dotNet = true; envelope.setOutputSoapObject(request); HttpTransportSE ht = new HttpTransportSE(URL); try { ht.call(SOAP_ACTION, envelope); //ht.call(null, envelope); Object object = envelope.getResponse(); result = object.toString(); Log.i("tag", result); } catch (Exception e) { e.printStackTrace(); } Log.i("TAG","result"+result); return result; }。

无法从服务器获取图像到Android应用程序

<div class="post-text" itemprop="text"> <p>i am building application which have the ability to search users and get there information. the situation is that when i run it on the emulator everything is fine but when i run it on my real server sometimes i get the user detailed and sometimes not. i don't know why i get some users and other not. i check and the users that was does not exist i get the failed message but for other users that exists i get the message.</p> <p>for example: correct result:</p> <pre><code> {"flag":"user found","users":[{"name":"nir","email":"nirb@g.com","mobile":"0543536434","image":"\/9j\/4AAQSkZJRgABAQAAAQABAAD\/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH\/2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH\/wAARCAB4AHgDASIAAhEBAxEB\/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL\/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6\/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL\/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6\/9oADAMBAAIRAxEAPwD+hr\/gmP8A8Ex\/+CZ3j\/8A4Jnf8E7fHnjz\/gnb+xB408a+NP2IP2R\/FnjLxl4t\/ZH\/AGfPEXizxZ4s8Rfs+\/DzWPEXifxP4i1j4c3uq6\/4g1\/Vby71XWta1W8udT1PU7m6v9Qu57uaad\/t\/wD4dNf8Eo\/+kY37AH\/iFv7NX\/zsKP8Agk1\/yii\/4Jjf9mAfsWf+s1\/DOvv+gD4A\/wCHTX\/BKP8A6RjfsAf+IW\/s1f8AzsKP+HTX\/BKP\/pGN+wB\/4hb+zV\/87Cvv+igD4A\/4dNf8Eo\/+kY37AH\/iFv7NX\/zsKP8Ah01\/wSj\/AOkY37AH\/iFv7NX\/AM7Cvv8AooA+AP8Ah01\/wSj\/AOkY37AH\/iFv7NX\/AM7Cj\/h01\/wSj\/6RjfsAf+IW\/s1f\/Owr7\/ooA+AP+HTX\/BKP\/pGN+wB\/4hb+zV\/87Cj\/AIdNf8Eo\/wDpGN+wB\/4hb+zV\/wDOwr7\/AKKAPgD\/AIdNf8Eo\/wDpGN+wB\/4hb+zV\/wDOwo\/4dNf8Eo\/+kY37AH\/iFv7NX\/zsK+\/6KAPgD\/h01\/wSj\/6RjfsAf+IW\/s1f\/Owo\/wCHTX\/BKP8A6RjfsAf+IW\/s1f8AzsK+\/wCigD8If+Cm\/wDwTH\/4JneAP+CZ3\/BRPx54D\/4J2\/sQeC\/Gvgv9iD9rfxZ4N8ZeE\/2R\/wBnzw74s8J+LPDv7PvxK1jw74n8MeItH+HNlqugeINA1Wxs9V0XWtKvLbU9M1O1tL+wu4buCGcFfb\/\/AAVk\/wCUUX\/BTr\/swD9tH\/1mv4qUUAH\/AASa\/wCUUX\/BMb\/swD9iz\/1mv4Z19\/18Af8ABJr\/AJRRf8Exv+zAP2LP\/Wa\/hnX3\/QAUUVUnvra3JEsm0j29yPX\/AGT\/AIk9Wk27RTb7JNvtsr\/156kylGKcpSUUt22kt2ur8vz3s27dFZsWrWEzbI5stxxjGeSB1PfHH4jJIOZbm9t7a2kuJHwiq5De6iQ+vptPXpkknBIfJO6XLK70Ss7t6LTT+teqbIVei4ykqsHGCvKSkmkrtXbvZbdX1Wrs2W2dV+8cfn9PQ\/57k80zzov74\/I\/4V+Of7RH7ffiTwFrWoaN4W8q6ms50jZDN5ZAM7qesL5O1c44GAM5JyfmD\/h5x8Xv+gdH\/wCBqf8AyJX7FlPgXx5nGAoZhh8NgoUa8YzpqtjIUqjhJJxk4SjdJxs0\/wDFq7a\/zPxD9LPwm4czbF5Pi8ZmVXE4Oo6VaWFy6rXoqcZzhKKqU5uLacHdXutG1rY\/or86L++PyP8AhQJoj0cfr7j0\/wBk\/wD1up\/nU\/4eb\/F7\/oHR\/wDgan\/yLSr\/AMFOPi8P+YbEf969T1b\/AKdPbvxgrk8bq9H\/AIl48Q\/+fWW\/+HCl\/keKvpn+DvWvnPT\/AJk+JXV33n2Sdt9bXumf0XKQwypyPXn6d\/8APuDzS1+Z37K37ZN\/8XrnTtI8QSx2+p3RtA1usgl5kcK3Plp\/ERwBjGDlgWr9L0ZZF3Kcj1\/Ej+mfp34NflPEfDWbcK5jUyvN6Ko4mmr2jLmhKPNKPNCa0lH3bpq6d97q5\/Q3A\/HXD3iHklPPuHMTLEYKo4xvUg6dWE3FtwqU3JypzSteMtd+qkOooorwD7E+AP8AgrJ\/yii\/4Kdf9mAfto\/+s1\/FSij\/AIKyf8oov+CnX\/ZgH7aP\/rNfxUooAP8Agk1\/yii\/4Jjf9mAfsWf+s1\/DOvv+vgD\/AIJNf8oov+CY3\/ZgH7Fn\/rNfwzr7\/oA8k+Jvxg8J\/DGznk8Q3q20ghWSMmaOM4JOD+8YY49MnoME4r8avjt+3f421PxnFYfCvWmm09nuIm8u\/lxvDhEG2BnUchgAeR0yWBz2f\/BU3xTrGjeI\/Dmn2Nz5Vvd29qs0e0\/Optb1m5DA8lFJGD25yAa+Cf2W7PwlqnxE0K28S2puUnu180GRUB3XMfmY3K2M7hySeSc5xX9Z+F\/h3w9g+D4cd5rg5ZxVrYLEVoYCcIVKMYw9pFt058q5k6bcXzaJq6b3\/wA6vHjxn4yzLxKxHhLw9mkeHcPh80wOErZvSnUo4lyqTpzilWpyl7jVS004Xta3wtv26x\/bR+P2g6iH1zU5o7dCPMY3t6uNruG+\/wAcjPXpgZIzkfVGqft96Pe\/DS2hGvZ8SN54uV\/tBSxVowqclw\/3txw2RgjoRkwftmeEvgtovw81xvDej\/ZtYRLvyphdRPgiGcr8ohUkkqDjd14yRnP4h19zw1wnwT4i5Zhs6\/1b\/sR4PFxSo06VKi6\/JBtc6i53pPmdldO\/flufk3GniF4peC+d5hwu+NVxRHMcuTeJq4nEYhYVVKrX7uU\/Z8lePsbXs1ZvVt69n4+8RP4r8V6trkknmtey7y+7dnBfuSfXsecnkgAnjK39A8Oaj4ju0s7FGMjyJGp8t2G5iAOn4Z78gYJ6\/avw\/wD2Cfi34wt4b62Fr5EiRzKJLWfJjcv\/ALeAcEZ79R82Of1rMM\/4d4WwlKnmmZ4XL6NKlTpUo158t4U1OMVFJdor\/h73\/njJOD+M+Pcfiq2RZJj85xGIr1K+InhaTqWqVqk5SlJyknZyu27vzbdrfBdFfq5J\/wAE2\/icbR1SOz87y12k28+S\/wAwP8XTuehxjk5FfNvxJ\/Yq+Knw4gubzVVgaGBd7iK1nU7d0mMEs3OAc+oKnoGryMt8SeCc1r\/VsJxBgJ15SUadL2r5qjbSXKnFbu3lqrNvf6TOfBHxSyHBzx+YcH5tTwlOLnVr\/V1yUopNvnfPdWSbe6tbVt2PKv2fviU\/wx8e6f4h+0\/Z0tpIG3+aYx+7mD8tu4+7n2BbgjJr9q\/DP\/BQT4bjR4BqviFftv8Ay1\/0+3\/D7zk9+\/qRjqa\/ntv9PuNOna3uFKuuc5Vl6MVPBHtn15HrmqNcXF3hnw1xxiKOOzRVlWp04whWw8oRcqcXJxTbi7rV6dHZ7s9Pw38c+OfCnB4vKs </code></pre> <p>when it failed i get:</p> <pre><code>{"flag":"user not found"} </code></pre> <p>for other existing users:</p> <pre><code> &lt;html&gt;&lt;head&gt;&lt;meta http-equiv="refresh" content="0;http://biz.nf/errors/403.html" /&gt;&lt;/head&gt;&lt;body&gt;&lt;/body&gt;&lt;/html&gt; </code></pre> <p>i do not have any idea why its happend:</p> <p>i just found that if i take off those 2 lines </p> <pre><code>$img_path = "images/".$row["image"]; $imgdata = base64_encode(file_get_contents($img_path)); and "image" =&gt; $imgdata </code></pre> <p>the result is fine. does my image decoding process correct? because in 1 user i get the image but in others not. </p> <p>this is my java code:</p> <pre><code> package com.example.matant.gpsportclient.Controllers; import android.content.Intent; import android.graphics.Bitmap; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.support.v7.internal.widget.AdapterViewCompat; import android.text.Editable; import android.text.TextWatcher; import android.util.Log; import android.view.View; import android.widget.AdapterView; import android.widget.Button; import android.widget.EditText; import android.widget.ImageView; import android.widget.ListView; import android.widget.Toast; import com.example.matant.gpsportclient.AsyncResponse; import com.example.matant.gpsportclient.R; import com.example.matant.gpsportclient.Utilities.ImageConvertor; import com.example.matant.gpsportclient.Utilities.InviteUsersArrayAdapter; import com.example.matant.gpsportclient.Utilities.InviteUsersListRow; import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import java.util.ArrayList; import java.util.List; public class InviteUsersActivity extends AppCompatActivity implements AsyncResponse, View.OnClickListener{ private EditText editTextSearch; private Button btnSave,btnDiscard; private ListView usersListView; private List&lt;InviteUsersListRow&gt; rowUser; private DBcontroller dbController; public static final String EXTRA_USERS = ""; ListView listViewUsers; List&lt;InviteUsersListRow&gt; rowUsers; private InviteUsersArrayAdapter Useradapter = null; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_invite_users); editTextSearch = (EditText) findViewById(R.id.editTextSearch); btnSave = (Button) findViewById(R.id.ButtonSave); btnDiscard = (Button)findViewById(R.id.ButtonDiscard); editTextSearch.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if(editTextSearch.getText().length() &gt; 0) { Log.d("send request","searching..."); sendDataToDBController(); } else{ Log.d("do nothing","doing nothing"); if(Useradapter != null) { Log.d("do nothing","clear adapter"); /*Useradapter.clear(); Useradapter.notifyDataSetChanged();*/ listViewUsers.setAdapter(null); } } } @Override public void afterTextChanged(Editable s) { } }); btnDiscard.setOnClickListener(this); listViewUsers = (ListView) findViewById(R.id.listViewusers); listViewUsers.setItemsCanFocus(true); btnSave.setOnClickListener(this); } @Override public void handleResponse(String resStr) { Log.d("invite_Response", resStr); if (resStr != null) { try { JSONObject json = new JSONObject(resStr); String flg = json.getString("flag"); Log.d("flag",flg); switch (flg){ case "user found":{ JSONArray jsonarr = json.getJSONArray("users"); Log.d("array",jsonarr.toString()); rowUsers = new ArrayList&lt;InviteUsersListRow&gt;(); for(int i = 0; i &lt; jsonarr.length();i++){ { Log.d("user is", jsonarr.getJSONObject(i).toString()); String name = jsonarr.getJSONObject(i).getString("name"); String mobile = jsonarr.getJSONObject(i).getString("mobile"); Bitmap profileImage = ImageConvertor.decodeBase64(jsonarr.getJSONObject(i).getString("image")); int imgStatus = R.drawable.add_user_50; if(Useradapter != null){ Log.d("Useradapter invited size:",String.valueOf(Useradapter.getUsers().size())); for(int j = 0 ;j&lt;Useradapter.getUsers().size();j++) { if(Useradapter.getUsers().get(j).getDesc().equals(mobile)) { imgStatus = R.drawable.remove_user_50; Log.d("set status2.1",String.valueOf(imgStatus)); break; } } }else{ imgStatus = R.drawable.add_user_50; Log.d("set status1",String.valueOf(imgStatus)); } InviteUsersListRow rowUser = new InviteUsersListRow(imgStatus, name, mobile,profileImage); rowUsers.add(rowUser); } if(Useradapter == null) Useradapter = new InviteUsersArrayAdapter(this,R.layout.invite_users_listview_row,rowUsers); else { { Useradapter.setData(rowUsers); Useradapter.notifyDataSetChanged(); } } listViewUsers.setAdapter(Useradapter); } break; } } } catch (JSONException e) { e.printStackTrace(); } }else Log.d("ServiceHandler", "Couldn't get any data from the url"); } @Override public void sendDataToDBController() { String username = editTextSearch.getText().toString(); BasicNameValuePair tagreq = new BasicNameValuePair("tag", "search_user"); BasicNameValuePair name = new BasicNameValuePair("name", username); List&lt;NameValuePair&gt; nameValuePairList = new ArrayList&lt;NameValuePair&gt;(); nameValuePairList.add(tagreq); nameValuePairList.add(name); dbController = new DBcontroller(this,this); dbController.execute(nameValuePairList); } @Override public void preProcess() { } @Override public void onClick(View v) { switch (v.getId()) { case R.id.ButtonDiscard: { Intent i = new Intent(); setResult(RESULT_CANCELED,i);; finish(); break; } case R.id.ButtonSave: { if(Useradapter != null ) { if(Useradapter.getUsers().size() &gt; 0) { Log.d("adapter size:",String.valueOf(Useradapter.getUsers().size())); Intent i = getIntent(); JSONArray jsonArr = new JSONArray(); for(int j = 0 ;j &lt; Useradapter.getUsers().size();j++) { try { JSONObject jsonObj = new JSONObject(); jsonObj.put("name",Useradapter.getUsers().get(j).getTitle()); jsonObj.put("mobile",Useradapter.getUsers().get(j).getDesc()); jsonArr.put(jsonObj); } catch (JSONException e) { e.printStackTrace(); } } Log.d("json users",jsonArr.toString()); i.putExtra("userList", jsonArr.toString()); setResult(RESULT_OK, i); finish(); } else{ Log.d("adapter size &lt;0", "search is empty"); Toast.makeText(this, "Please select user!", Toast.LENGTH_SHORT).show(); } } } break; } } } </code></pre> <p>this is the server side:</p> <pre><code>&lt;?php /** * Created by PhpStorm. * User: matant * Date: 9/24/2015 * Time: 11:29 AM */ include 'response_process.php'; class SearchUser implements ResponseProcess{ public function dataProcess($dblink) { $output = array(); $name = $_POST["name"]; $output["flag"]="user found"; $query = "SELECT * FROM users WHERE users.name LIKE '$name%'"; $result = mysqli_query($dblink,$query) or die (mysqli_error($dblink)); if(!$result){ $output["flag"] = "query failed"; $output["query_msg"] = $result; }else{ $no_of_rows = mysqli_num_rows($result); if ($no_of_rows &lt; 1) $output["flag"]="user not found"; //user not found else{ $output["flag"]="user found"; $output["users"] = array(); while($row = mysqli_fetch_assoc($result)) { $img_path = "images/".$row["image"]; $imgdata = base64_encode(file_get_contents($img_path)); $output["users"][] = array("name"=&gt; $row["name"],"email"=&gt; $row["email"],"mobile" =&gt; $row["mobile"],"image" =&gt; $imgdata); } } } echo json_encode($output); } } </code></pre> </div>

安卓中的问题,大家帮忙看看

import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.os.StrictMode; import android.util.Log; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; import org.json.JSONArray; import org.json.JSONObject; import android.annotation.SuppressLint; import android.app.Activity; import android.app.ProgressDialog; import android.content.Context; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; public class LieBiao extends Activity { ListView listView; String [] titles={"汽车1","汽车2","汽车3","汽车4"}; String [] texts={"详细信息A","详细信息B","详细信息C","详细信息D"}; String [] mm={"1","2","2","2"}; // String [] titles2; // String [] texts2; // String [] mm2; int [] resIds={R.drawable.mycar,R.drawable.mycar,R.drawable.mycar,R.drawable.mycar}; public String ServerUrl = "http://192.168.11.245:1234/sss/Remote/"; public ProgressDialog progressDialog1; private SharedPreferences preferences; private Editor editor; private String loginName; // public int test ; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); //防止线程阻塞 StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() .detectDiskReads().detectDiskWrites().detectNetwork() .penaltyLog().build()); StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder() .detectLeakedSqlLiteObjects().detectLeakedClosableObjects() .penaltyLog().penaltyDeath().build()); progressDialog1 = ProgressDialog.show(LieBiao.this, "", "服务器连接中...", true, false); new Thread() { @Override public void run() { // 向handler发消息 handler.sendEmptyMessage(0); } }.start(); // if (test == 1) { // this.setTitle("您的汽车信息如下"); // //拿到listview对象 // listView=(ListView)this.findViewById(R.id.MyListView); // // //设置实时更新数据 // // listView.setAdapter(new ListViewAdapter(titles,texts,resIds)); // for(int i=0;i<titles.length;i++){//循环数组,arr.length是数组长度 // System.out.println(titles[i]);//打印数组中的元素 // } // } this.setTitle("您的汽车信息如下"); //拿到listview对象 listView=(ListView)this.findViewById(R.id.MyListView); //设置实时更新数据 listView.setAdapter(new ListViewAdapter(titles,texts,resIds)); for(int i=0;i<titles.length;i++){//循环数组,arr.length是数组长度 System.out.println(titles[i]);//打印数组中的元素 } } private Handler handler = new Handler() { @SuppressLint("HandlerLeak") @Override public void handleMessage(Message msg) { // 查询操作 searchcar(); } }; private void searchcar() { String brand = null; String color = null; String style = null; String oilMass = null; String plateNumber = null; // 打开网络连接 HttpClient client = new DefaultHttpClient(); StringBuilder builder = new StringBuilder(); // 服务器提交地址 HttpGet myget = new HttpGet(ServerUrl + "MyCar.ashx?type=mycar&LoginName=123" //+ loginName //+ editText1.getText().toString() ); try { HttpResponse response = client.execute(myget); BufferedReader reader = new BufferedReader(new InputStreamReader( response.getEntity().getContent())); // 填充数据流 for (String s = reader.readLine(); s != null; s = reader.readLine()) { builder.append(s); } Log.i("cat", ">>>>>>" + builder.toString()); // 读取json返回数组 JSONObject jsonObject = new JSONObject(builder.toString()); JSONArray jsonArray = jsonObject.getJSONArray("rows"); ArrayList<String> brandlist = new ArrayList<String>(); ArrayList<String> colorlist = new ArrayList<String>(); ArrayList<String> stylelist = new ArrayList<String>(); ArrayList<String> oilMasslist = new ArrayList<String>(); ArrayList<String> plateNumberlist = new ArrayList<String>(); for(int i=0;i<jsonArray.length();i++){ JSONObject jsonObject2 = (JSONObject)jsonArray.opt(i); brand = jsonObject2.getString("JSON_品牌"); brandlist.add(brand); color = jsonObject2.getString("JSON_颜色"); colorlist.add(color); style = jsonObject2.getString("JSON_车型"); stylelist.add(style); oilMass = jsonObject2.getString("JSON_油量"); oilMasslist.add(oilMass); plateNumber = jsonObject2.getString("JSON_车牌号"); plateNumberlist.add(plateNumber); } Log.i("cat", ">>>>>>" + brandlist.toString()); Log.i("cat", ">>>>>>" + colorlist.toString()); Log.i("cat", ">>>>>>" + stylelist.toString()); Log.i("cat", ">>>>>>" + oilMasslist.toString()); Log.i("cat", ">>>>>>" + plateNumberlist.toString()); titles = (String[]) brandlist.toArray(new String[brandlist.size()]); texts = (String[]) colorlist.toArray(new String[colorlist.size()]); mm = (String[]) stylelist.toArray(new String[stylelist.size()]); for(int i=0;i<titles.length;i++){//循环数组,arr.length是数组长度 System.out.println(titles[i]);//打印数组中的元素 } Toast.makeText(LieBiao.this, "查询成功", Toast.LENGTH_SHORT) .show(); // test = 1; progressDialog1.dismiss(); } catch (Exception e) { //Log.v("url返回", "false"); e.printStackTrace(); Toast.makeText(LieBiao.this, "服务器数据查询失败", Toast.LENGTH_SHORT) .show(); progressDialog1.dismiss(); } } //定义适配器 public class ListViewAdapter extends BaseAdapter{ View [] itemViews; public ListViewAdapter(String [] itemTitles, String [] itemTexts, int [] itemImageRes){ itemViews = new View[itemTitles.length]; for (int i=0; i<itemViews.length; ++i){ itemViews[i] = makeItemView(itemTitles[i], itemTexts[i], itemImageRes[i]); } } public int getCount() { return itemViews.length; } public View getItem(int position) { return itemViews[position]; } public long getItemId(int position) { return position; } private View makeItemView(String strTitle, String strText, int resId) { LayoutInflater inflater = (LayoutInflater)LieBiao.this .getSystemService(Context.LAYOUT_INFLATER_SERVICE); // 使用View的对象itemView与R.layout.item关联 View itemView = inflater.inflate(R.layout.listview_item, null); // 通过findViewById()方法实例R.layout.item内各组件 TextView title = (TextView)itemView.findViewById(R.id.text0); title.setText(strTitle); TextView text = (TextView)itemView.findViewById(R.id.text1); text.setText(strText); ImageView image = (ImageView)itemView.findViewById(R.id.mycar); image.setImageResource(resId); return itemView; } public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) return itemViews[position]; return convertView; } } } 我想问一下titles数组在这一句 titles = (String[]) brandlist.toArray(new String[brandlist.size()]); 我又重新赋值了,为什么这一句 listView.setAdapter(new ListViewAdapter(titles,texts,resIds)); 里面的titles的值还是一开始赋的值 String [] titles={"汽车1","汽车2","汽车3","汽车4"}; 到底是什么问题,我不清楚,新人求教各位大神! 谢谢

expandableListView 怎么把后台的数据存放起来

private ExpandableListView expandableListView; private List<String> group_list;//表示它有几个分组 存放组名 private List<String> item_lt;//每个分组下面有多少人 存放组里的人民 private List<List<String>> item_list; private List<List<Integer>> item_list2;//存放头像的List private List<List<Integer>> gr_list2; private List<T> list=new ArrayList<T>();//把后台传过来的值保存到list里面 private MyExpandableListViewAdapter adapter; String zddres=null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { //setContentView(R.layout.activity_main); View view=inflater.inflate(R.layout.fragment_lianxiren,null); houtaicaixun(); // private List<String> group_list;//表示它有几个分组 // 随便一堆测试数据 group_list = new ArrayList<String>(); group_list.add(zddres); group_list.add("我的家人"); group_list.add("兄弟姐妹"); group_list.add("我的同学"); //private List<String> item_lt;//每个分组下面有多少人 item_lt = new ArrayList<String>(); item_lt.add("张三"); item_lt.add("董存瑞"); item_lt.add("李大钊"); item_list = new ArrayList<List<String>>(); item_list.add(item_lt); item_list.add(item_lt); item_list.add(item_lt); item_list.add(item_lt); List<Integer> tmp_list = new ArrayList<Integer>();//存放头像 tmp_list.add(R.drawable.ic_launcher); tmp_list.add(R.drawable.ic_launcher); tmp_list.add(R.drawable.ic_launcher); tmp_list.add(R.drawable.ic_launcher); item_list2 = new ArrayList<List<Integer>>();//存放头像 item_list2.add(tmp_list); item_list2.add(tmp_list); item_list2.add(tmp_list); item_list2.add(tmp_list); List<Integer> gr_list = new ArrayList<Integer>(); gr_list.add(R.drawable.qb_right); gr_list.add(R.drawable.qb_right); gr_list.add(R.drawable.qb_right); gr_list.add(R.drawable.qb_right); //···· 这个感觉没什么用 gr_list2 = new ArrayList<List<Integer>>(); gr_list2.add(gr_list); gr_list2.add(gr_list); gr_list2.add(gr_list); gr_list2.add(gr_list); expandableListView = (ExpandableListView)view.findViewById(R.id.expendlist); expandableListView.setGroupIndicator(null); // 监听组点击 expandableListView.setOnGroupClickListener(new OnGroupClickListener() { @SuppressLint("NewApi") @Override public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { if (item_list.get(groupPosition).isEmpty()) { return true; } return false; } }); // 监听每个分组里子控件的点击事件 expandableListView.setOnChildClickListener(new OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { Toast.makeText(getActivity(), "group=" + groupPosition + "---child=" + childPosition + "---" + item_list.get(groupPosition).get(childPosition), Toast.LENGTH_SHORT).show(); return false; } }); adapter = new MyExpandableListViewAdapter(this.getActivity()); expandableListView.setAdapter(adapter); return view; } // 用过ListView的人一定很熟悉,只不过这里是BaseExpandableListAdapter class MyExpandableListViewAdapter extends BaseExpandableListAdapter { private Context context; public MyExpandableListViewAdapter(Context context) { this.context = context; } /** * * 获取组的个数 * * @return * @see android.widget.ExpandableListAdapter#getGroupCount() */ @Override public int getGroupCount() { return group_list.size(); } /** * * 获取指定组中的子元素个数 * * @param groupPosition * @return * @see android.widget.ExpandableListAdapter#getChildrenCount(int) */ @Override public int getChildrenCount(int groupPosition) { return item_list.get(groupPosition).size(); } /** * * 获取指定组中的数据 * * @param groupPosition * @return * @see android.widget.ExpandableListAdapter#getGroup(int) */ @Override public Object getGroup(int groupPosition) { return group_list.get(groupPosition); } /** * * 获取指定组中的指定子元素数据。 * * @param groupPosition * @param childPosition * @return * @see android.widget.ExpandableListAdapter#getChild(int, int) */ @Override public Object getChild(int groupPosition, int childPosition) { return item_list.get(groupPosition).get(childPosition); } /** * * 获取指定组的ID,这个组ID必须是唯一的 * * @param groupPosition * @return * @see android.widget.ExpandableListAdapter#getGroupId(int) */ @Override public long getGroupId(int groupPosition) { return groupPosition; } /** * * 获取指定组中的指定子元素ID * * @param groupPosition * @param childPosition * @return * @see android.widget.ExpandableListAdapter#getChildId(int, int) */ @Override public long getChildId(int groupPosition, int childPosition) { return childPosition; } /** * * 组和子元素是否持有稳定的ID,也就是底层数据的改变不会影响到它们。 * * @return * @see android.widget.ExpandableListAdapter#hasStableIds() */ @Override public boolean hasStableIds() { return true; } /** * * 获取显示指定组的视图对象 * * @param groupPosition 组位置 * @param isExpanded 该组是展开状态还是伸缩状态 * @param convertView 重用已有的视图对象 * @param parent 返回的视图对象始终依附于的视图组 * @return * @see android.widget.ExpandableListAdapter#getGroupView(int, boolean, android.view.View, * android.view.ViewGroup) */ @Override public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { GroupHolder groupHolder = null; if (convertView == null) { convertView = LayoutInflater.from(context).inflate(R.layout.expendlist_group, null); groupHolder = new GroupHolder(); groupHolder.txt = (TextView)convertView.findViewById(R.id.txt); groupHolder.img = (ImageView)convertView.findViewById(R.id.img); convertView.setTag(groupHolder); } else { groupHolder = (GroupHolder)convertView.getTag(); } if (!isExpanded)//不是展开状态 { groupHolder.img.setBackgroundResource(R.drawable.qb_right); } else//展开状态 { groupHolder.img.setBackgroundResource(R.drawable.qb_down); } //设置组名 groupHolder.txt.setText(group_list.get(groupPosition)); return convertView; } /** * * 获取一个视图对象,显示指定组中的指定子元素数据。 * * @param groupPosition 组位置 * @param childPosition 子元素位置 * @param isLastChild 子元素是否处于组中的最后一个 * @param convertView 重用已有的视图(View)对象 * @param parent 返回的视图(View)对象始终依附于的视图组 * @return * @see android.widget.ExpandableListAdapter#getChildView(int, int, boolean, android.view.View, * android.view.ViewGroup) */ @Override public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { ItemHolder itemHolder = null; if (convertView == null) { convertView = LayoutInflater.from(context).inflate(R.layout.expendlist_item, null); itemHolder = new ItemHolder(); itemHolder.txt = (TextView)convertView.findViewById(R.id.txt); itemHolder.img = (ImageView)convertView.findViewById(R.id.img); convertView.setTag(itemHolder); } else { itemHolder = (ItemHolder)convertView.getTag(); } //设置每个组里有多少人 itemHolder.txt.setText(item_list.get(groupPosition).get(childPosition)); itemHolder.img.setBackgroundResource(item_list2.get(groupPosition).get(childPosition)); return convertView; } /** * * 是否选中指定位置上的子元素。 * * @param groupPosition * @param childPosition } ![图片说明](https://img-ask.csdn.net/upload/201610/20/1476951675_929263.jpg) ![图片说明](https://img-ask.csdn.net/upload/201610/20/1476952030_433854.jpg) 如何把这个Json字符串里的值放到那几个List 去

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

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

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

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

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

和黑客斗争的 6 天!

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

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

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

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

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

总结了 150 余个神奇网站,你不来瞅瞅吗?

原博客再更新,可能就没了,之后将持续更新本篇博客。

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

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

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

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

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

外包程序员的幸福生活

今天给你们讲述一个外包程序员的幸福生活。男主是Z哥,不是在外包公司上班的那种,是一名自由职业者,接外包项目自己干。接下来讲的都是真人真事。 先给大家介绍一下男主,Z哥,老程序员,是我十多年前的老同事,技术大牛,当过CTO,也创过业。因为我俩都爱好喝酒、踢球,再加上住的距离不算远,所以一直也断断续续的联系着,我对Z哥的状况也有大概了解。 Z哥几年前创业失败,后来他开始干起了外包,利用自己的技术能...

优雅的替换if-else语句

场景 日常开发,if-else语句写的不少吧??当逻辑分支非常多的时候,if-else套了一层又一层,虽然业务功能倒是实现了,但是看起来是真的很不优雅,尤其是对于我这种有强迫症的程序"猿",看到这么多if-else,脑袋瓜子就嗡嗡的,总想着解锁新姿势:干掉过多的if-else!!!本文将介绍三板斧手段: 优先判断条件,条件不满足的,逻辑及时中断返回; 采用策略模式+工厂模式; 结合注解,锦...

深入剖析Springboot启动原理的底层源码,再也不怕面试官问了!

大家现在应该都对Springboot很熟悉,但是你对他的启动原理了解吗?

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

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

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

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

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

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

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

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中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多个条件是什么逻辑关系?条件判断在什么时候执...

你期望月薪4万,出门右拐,不送,这几个点,你也就是个初级的水平

先来看几个问题通过注解的方式注入依赖对象,介绍一下你知道的几种方式@Autowired和@Resource有何区别说一下@Autowired查找候选者的...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

《Oracle Java SE编程自学与面试指南》最佳学习路线图2020年最新版(进大厂必备)

正确选择比瞎努力更重要!

《Oracle Java SE编程自学与面试指南》最佳学习路线图(2020最新版)

正确选择比瞎努力更重要!

字节跳动面试官竟然问了我JDBC?

轻松等回家通知

面试官:你连SSO都不懂,就别来面试了

大厂竟然要考我SSO,卧槽。

终于,月薪过5万了!

来看几个问题想不想月薪超过5万?想不想进入公司架构组?想不想成为项目组的负责人?想不想成为spring的高手,超越99%的对手?那么本文内容是你必须要掌握的。本文主要详解bean的生命...

自从喜欢上了B站这12个UP主,我越来越觉得自己是个废柴了!

不怕告诉你,我自从喜欢上了这12个UP主,哔哩哔哩成为了我手机上最耗电的软件,几乎每天都会看,可是吧,看的越多,我就越觉得自己是个废柴,唉,老天不公啊,不信你看看…… 间接性踌躇满志,持续性混吃等死,都是因为你们……但是,自己的学习力在慢慢变强,这是不容忽视的,推荐给你们! 都说B站是个宝,可是有人不会挖啊,没事,今天咱挖好的送你一箩筐,首先啊,我在B站上最喜欢看这个家伙的视频了,为啥 ,咱撇...

代码注释如此沙雕,会玩还是你们程序员!

某站后端代码被“开源”,同时刷遍全网的,还有代码里的那些神注释。 我们这才知道,原来程序员个个都是段子手;这么多年来,我们也走过了他们的无数套路… 首先,产品经理,是永远永远吐槽不完的!网友的评论也非常扎心,说看这些代码就像在阅读程序员的日记,每一页都写满了对产品经理的恨。 然后,也要发出直击灵魂的质问:你是尊贵的付费大会员吗? 这不禁让人想起之前某音乐app的穷逼Vip,果然,穷逼在哪里都是...

2020春招面试了10多家大厂,我把问烂了的数据库事务知识点总结了一下

2020年截止目前,我面试了阿里巴巴、腾讯、美团、拼多多、京东、快手等互联网大厂。我发现数据库事务在面试中出现的次数非常多。

爬虫(101)爬点重口味的

小弟最近在学校无聊的很哪,浏览网页突然看到一张图片,都快流鼻血。。。然后小弟冥思苦想,得干一点有趣的事情python 爬虫库安装https://s.taobao.com/api?_ks...

在拼多多上班,是一种什么样的体验?我心态崩了呀!

之前有很多读者咨询我:武哥,在拼多多上班是一种什么样的体验?由于一直很忙,没抽出时间来和大家分享。上周末特地花点时间来写了一篇文章,跟大家分享一下拼多多的日常。 1. 倒时差的作息 可能很多小伙伴都听说了,拼多多加班很严重。这怎么说呢?作息上确实和其他公司有点区别,大家知道 996,那么自然也就能理解拼多多的“11 11 6”了。 所以当很多小伙伴早上出门时,他们是这样的: 我们是这样的: 当...

应聘3万的职位,有必要这么刁难我么。。。沙雕。。。

又一次被面试官带到坑里面了。面试官:springmvc用过么?我:用过啊,经常用呢面试官:springmvc中为什么需要用父子容器?我:嗯。。。没听明白你说的什么。面试官:就是contr...

太狠了,疫情期间面试,一个问题砍了我5000!

疫情期间找工作确实有点难度,想拿到满意的薪资,确实要点实力啊!面试官:Spring中的@Value用过么,介绍一下我:@Value可以标注在字段上面,可以将外部配置文件中的数据,比如可以...

自学编程的 6 个致命误区

嗨,小伙伴们大家好,我是沉默王二。本篇文章来和大家聊聊自学编程中的一些误区——这是我在 B 站上看了羊哥的一期视频后有感而发的文章。因为确实有很多读者也曾私信问过我这些方面的问题,很有代表性,所以我就结合自己的亲身体会来谈一谈,希望对小伙伴们有所启发。 01、追求时髦 所谓基础不牢,地动山摇啊。可很多小伙伴压根就没注意过这个问题,市面上出什么新鲜的技术就想去尝试,结果把自己学的乱七八糟,心灰意冷...

祝贺玄姐,创业两个月,估值近亿,融资几千万,奈学教育,太牛逼了!!!...

玄姐,男,前58同城技术委员会主席,前转转首席架构师,我的10年好友。一月下旬,玄姐找到我,说,哥们我准备创业了。画外音:详见《最好的朋友创业了,我必须为他站台》。番外篇《为何大家都叫...

你看,公司状告员工不加班,居然还告赢了

loonggg读完需要3分钟速读仅需 1 分钟今天跟大家聊一聊加班文化这个话题。今天微博热搜榜上有一个话题就是:#员工拒绝加班被判赔公司 1.8 万# 。具体什么情况呢?扬州某公司员工王...

在北京,我遇上每天必须挣1000元的出租车司机!

在北漂的那段时间几乎天天加班,只要加班必然晚上回家会坐出租车,北漂7年大概遇上了近1000个出租车司机。大家都知道,在北京住的的地方和公司一般距离都很远,就算是晚上10点或者11点的时候...

立即提问
相关内容推荐