fragment下点击button刷新该fragment

我要做一个登陆界面,有一个是否登录来判断载入哪个layout,在mainactivity中第一次调用的是一个登陆的fragment,登陆成功后更新这个fragment,要如何做?不是切换fragment。如果要替换的话我尝试在fragment写一个信息给MainActivity,可是还是会回到这个fragment,无法销毁。

1个回答

最简单的,在一个fragment的布局文件中写一个登录后的布局,没登录时设为隐藏

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

我在使用BottomNavigationView实现底部导航栏的时候,使用fragment进行页面的展示,其中home页面中加入了一个按钮,点击可以刷新textview中的文字 但是事件监听无效,一开始我以为是我写在了onCreateView方法中导致的,但是后来我百度之后,将事件监听写到了onActivityCreated方法中,依然无效。 以下是代码片段 ``` package com.example.test1; import android.os.Bundle; import android.support.annotation.NonNull; 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.ViewGroup; import android.widget.Button; import android.widget.TextView; import android.widget.Toast; public class HomeFragment extends Fragment { private Button button; private TextView textView; private View view; @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { view = inflater.inflate(R.layout.home, container, false); return view; } @Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); button = (Button) view.findViewById(R.id.zy); textView = (TextView) view.findViewById(R.id.test); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { textView.setText("响应点击事件成功"); } }); } } ``` 我自己尝试过debug,textview和button都获得了相应的值,但是无法响应事件: ![图片说明](https://img-ask.csdn.net/upload/202002/22/1582375649_472655.png) 现在可以展示切换fragment,但是fragment中的事件均无法响应

android fragment点击返回键实现内容切换?

我有一个fragment,上有一个button和textview,默认button是隐藏的,通过点击菜单栏上的一个详细信息的按钮,将button显示出来,现在有没有办法通过点击返回键实现返回上一个只有textview的页面???

viewpager中的两个Fragment,点击FB中的按钮跳转到FragmentA

ViewPager中有FragmentA和FragmentB,点击FragmentA中的按钮,跳转到FragmentA 跪求大神解答

fragment嵌套ListView,ListView里的button无效

如题。一样的代码,当我继承activity时,按钮是可以监听到的。当继承fragment时,button无效。getview是有执行的,adapter刷新也不起作用

viewpager中的fragment之间跳转传值问题?

有一个是Activity,在里面有viewpager的实现,ViewPager显示的是10个子fragment,ViewPager中使用的是FragmentStatePagerAdapter适配器。现在已经可以左右滑动切换1-10个Fragment了,我现在想实现的功能是:每个Fragment中都有几个button,点击第一个Fragment中的button,相当于右滑了一下,跳到了下一个Fragment。能跳过去了,但是从第一个fragment跳过去的时候第二个fragment为null?是怎么回事?

在安卓中,如何从activity跳转到fragment?大家有没有什么好的方法,谢谢大家。

在安卓中,如何从activity跳转到fragment?大家有没有什么好的方法,谢谢大家。

activity 点击按钮 刷新?????????

Listview 中的items中,点了个按钮 让activity刷新

为什么在fragment里面放的RecyclerView 没写加载会自动加载出来?

直接上代码 把加载fragment写在监听里可是程序一运行就已经显示了 package com.example.bmvod.fragment; import android.app.FragmentManager; import android.app.FragmentTransaction; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.view.Menu; import android.view.MenuItem; import android.view.View; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class MainActivity extends AppCompatActivity { private RecyclerView mRecyclerView; private GalleryAdapter mAdapter; private List<Integer> mDatas; private FirstFragment firstFragment; private SecondFragment secondFragment; // private ThirdFragment thirdFragment; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initDatas(); mRecyclerView = (RecyclerView) findViewById(R.id.recid1); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); mRecyclerView.setLayoutManager(linearLayoutManager); mAdapter = new GalleryAdapter(this, mDatas); mAdapter.setOnItemClickLitener(new GalleryAdapter.OnItemClickLitener() { @Override public void onItemClick(View view, int position) { FragmentManager fm = getFragmentManager(); FragmentTransaction transaction = fm.beginTransaction(); switch (position) { case 0: firstFragment = new FirstFragment(); transaction.add(R.id.fragment, firstFragment); hideAllFragments(transaction); transaction.show(firstFragment); break; case 1: secondFragment = new SecondFragment(); transaction.add(R.id.fragment, secondFragment); hideAllFragments(transaction); transaction.show(secondFragment); break; } transaction.commit(); } }); mRecyclerView.setAdapter(mAdapter); } private void hideAllFragments(FragmentTransaction ft) { if (firstFragment != null) { ft.hide(firstFragment); } if (secondFragment != null) { ft.hide(secondFragment); } } private void initDatas() { mDatas = new ArrayList<Integer>(Arrays.asList(R.drawable.bottom1, R.drawable.bottom2, R.drawable.bottom3, R.drawable.bottom4, R.drawable.bottom5, R.drawable.bottom1, R.drawable.bottom2, R.drawable.bottom3, R.drawable.bottom4)); } private void setDefaultFragment() { FragmentManager fm = getFragmentManager(); FragmentTransaction transaction = fm.beginTransaction(); firstFragment = new FirstFragment(); transaction.replace(R.id.fragment, firstFragment); transaction.commit(); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } } ``` ``` package com.example.bmvod.fragment; import android.app.Fragment; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import java.util.ArrayList; import java.util.Arrays; import java.util.List; /** * Created by bmvod on 2016/6/29. */ public class FirstFragment extends Fragment { private RecyclerView mRecyclerView; private GalleryAdapter2 mAdapter; private List<Integer> mDatas; @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.firstfragmentlayout, container, false); initDatas2(); mRecyclerView = (RecyclerView) view.findViewById(R.id.fragmengrecv1); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity()); linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); mRecyclerView.setLayoutManager(linearLayoutManager); mAdapter = new GalleryAdapter2(getActivity(), mDatas); mRecyclerView.setAdapter(mAdapter); return view; } private void initDatas2() { mDatas = new ArrayList<Integer>(Arrays.asList(R.drawable.smalltop1, R.drawable.smalltop2, R.drawable.smalltop3, R.drawable.smalltop4, R.drawable.smalltop5, R.drawable.smalltop1, R.drawable.smalltop2, R.drawable.smalltop3, R.drawable.smalltop4)); } } ``` ```

Android下拉列表刷新不出来

页面切换是用的Fragment+ViewPager来完成的,三个页面,SaveFragment,ShowFragment,SetFragment,现在在SaveFragment中设置了一个下拉刷新列表,想实现在ShowFragment中的Button点击,将数据保存,并在Save界面下拉刷新出列表,列表即Button点击保存的数据。这对于我来说挺难的,求大神指点,运行程序的时候总是不出现列表。代码贴出: ``` ShowFragment中的button点击事件的处理: btnSave.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View v){ Log.i(TAG,"执行数据保存操作!"); getActivity().runOnUiThread(new Runnable(){ @Override public void run(){ MainActivity mainActivity = (MainActivity)getActivity(); SaveFragment saveFragment = mainActivity.getSaveFragment(); //打算让列表以当前时间的名字的形式保存。 //设置时间格式 SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd/HH:mm:ss"); //获取当前时间 long time = System.currentTimeMillis(); //将long转化为Date Date date = new Date(time); String timeSave = format.format(date); Log.i(TAG,"timeSave = " + timeSave); if(saveFragment != null){ saveFragment.addDateForList(timeSave); saveFragment.notifyDataSetChanged(); Log.d(TAG,"date has been saved."); } } }) } }); ``` 两个fragment都已经在MainActivity中声明了, ``` 下拉刷新列表的代码如下,我感觉问题在这里,但是我不知道怎么改: RefreshableView refreshableView = (RefreshableView)view.findViewById(R.id.refreshable_view); refreshableView.setOnRefreshListener(new RefreshableView.PullToRefreshListener(){ @Override public void onRefresh(){ try{ //我觉得应该在try里面添加时间,但是不知道怎么去添加。。。 Thread.sleep(3000); }catch(InterruptedException e){ e.printStackTrace(); } refreshableView.finishRefreshing(); } },0); public void addDateForList(String date){ dateList.add(date); } public void notifyDataSetChanged(){ dateAdapter.notifyDataSetChanged(); } ``` 这是用到的主要的代码,程序运行的时候,用log来查看运行的情况的时候, if里面的log并没有打印出来,不知道怎么修改 ``` if(saveFragment != null){ saveFragment.addDateForList(timeSave); saveFragment.notifyDataSetChanged(); Log.d(TAG,"date has been saved."); } ``` 安卓自学小白一枚,求大神路过指教啊~

删除后android刷新Listview

在我的item删除后我想要刷新我的listview。但是好像不起作用,我是少了什么东西了么?我用了`listAdapter.notifyDataSetChanged();`也不起作用。有没有人能帮帮我?谢谢。 @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); getActivity().setContentView(R.layout.dl_listview); View empty = getActivity().findViewById(R.id.empty); DLListView = (ListView) getActivity().findViewById(R.id.DLListView); DLListView.setEmptyView(empty); if (!Environment.getExternalStorageState().equals( Environment.MEDIA_MOUNTED)) { Toast.makeText(getActivity(), "Error! No SDCARD Found!", Toast.LENGTH_LONG).show(); } else { File directory = new File(Environment.getExternalStorageDirectory() + File.separator + "St"); directory.mkdirs(); } DLListView = (ListView) getActivity().findViewById(R.id.DLListView); myList = new ArrayList<String>(); File sdCard = Environment.getExternalStorageDirectory(); file = new File(sdCard.getAbsolutePath() + "/St/"); File list[] = file.listFiles(); for (int i = 0; i < list.length; i++) { String fileName = list[i].getName(); fileName = fileName.replace(".txt", ""); myList.add(fileName); } listAdapter = new ArrayAdapter<String>(getActivity(), R.layout.simplerow, myList); DLListView.setAdapter(listAdapter); DLListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // TODO Auto-generated method stub String textToPass = myList.get(position); Intent i = new Intent(getActivity(), ViewActivity.class); textToPass = textToPass.replace(textToPass + "", textToPass + ".txt"); i.putExtra("textToPass", textToPass); startActivity(i); } }); DLListView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { // TODO Auto-generated method stub registerForContextMenu(DLListView); return false; } }); } public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; String name = ((TextView) info.targetView).getText().toString(); menu.setHeaderTitle(name); menu.add(0, v.getId(), 0, "Delete"); } @Override public boolean onContextItemSelected(MenuItem item) { deletefunc(item.getItemId()); return true; } public void deletefunc(int id) { String filenamec = fileName1; filenamec = filenamec.replace(filenamec + "", filenamec + ".txt"); File folder = Environment.getExternalStorageDirectory(); String fileName = folder.getPath() + "/St/" + filenamec; File myFile = new File(fileName); if (myFile.exists()) myFile.delete(); Toast.makeText(getActivity(), fileName1+" Deleted", Toast.LENGTH_SHORT) .show(); listAdapter.remove(listAdapter.getItem(id)); } LogCat : 12-26 11:57:27.334: E/AndroidRuntime(5576): FATAL EXCEPTION: main 12-26 11:57:27.334: E/AndroidRuntime(5576): java.lang.IndexOutOfBoundsException: Invalid index 2131034154, size is 1 12-26 11:57:27.334: E/AndroidRuntime(5576): at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251) 12-26 11:57:27.334: E/AndroidRuntime(5576): at java.util.ArrayList.get(ArrayList.java:304) 12-26 11:57:27.334: E/AndroidRuntime(5576): at android.widget.ArrayAdapter.getItem(ArrayAdapter.java:337) 12-26 11:57:27.334: E/AndroidRuntime(5576): at free.st.app.MyDownloads.deletefunc(MyDownloads.java:137) 12-26 11:57:27.334: E/AndroidRuntime(5576): at free.st.app.MyDownloads.onContextItemSelected(MyDownloads.java:118) 12-26 11:57:27.334: E/AndroidRuntime(5576): at android.support.v4.app.FragmentManagerImpl.dispatchContextItemSelected(FragmentManager.java:1933) 12-26 11:57:27.334: E/AndroidRuntime(5576): at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:360) 12-26 11:57:27.334: E/AndroidRuntime(5576): at com.actionbarsherlock.app.SherlockFragmentActivity.onMenuItemSelected(SherlockFragmentActivity.java:200) 12-26 11:57:27.334: E/AndroidRuntime(5576): at com.android.internal.policy.impl.PhoneWindow$DialogMenuCallback.onMenuItemSelected(PhoneWindow.java:3691) 12-26 11:57:27.334: E/AndroidRuntime(5576): at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:735) 12-26 11:57:27.334: E/AndroidRuntime(5576): at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:149) 12-26 11:57:27.334: E/AndroidRuntime(5576): at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874) 12-26 11:57:27.334: E/AndroidRuntime(5576): at com.android.internal.view.menu.MenuDialogHelper.onClick(MenuDialogHelper.java:167) 12-26 11:57:27.334: E/AndroidRuntime(5576): at com.android.internal.app.AlertController$AlertParams$3.onItemClick(AlertController.java:929) 12-26 11:57:27.334: E/AndroidRuntime(5576): at android.widget.AdapterView.performItemClick(AdapterView.java:292) 12-26 11:57:27.334: E/AndroidRuntime(5576): at android.widget.AbsListView.performItemClick(AbsListView.java:1185) 12-26 11:57:27.334: E/AndroidRuntime(5576): at android.widget.AbsListView$PerformClick.run(AbsListView.java:2713) 12-26 11:57:27.334: E/AndroidRuntime(5576): at android.widget.AbsListView$1.run(AbsListView.java:3468) 12-26 11:57:27.334: E/AndroidRuntime(5576): at android.os.Handler.handleCallback(Handler.java:605) 12-26 11:57:27.334: E/AndroidRuntime(5576): at android.os.Handler.dispatchMessage(Handler.java:92) 12-26 11:57:27.334: E/AndroidRuntime(5576): at android.os.Looper.loop(Looper.java:137) 12-26 11:57:27.334: E/AndroidRuntime(5576): at android.app.ActivityThread.main(ActivityThread.java:4512) 12-26 11:57:27.334: E/AndroidRuntime(5576): at java.lang.reflect.Method.invokeNative(Native Method) 12-26 11:57:27.334: E/AndroidRuntime(5576): at java.lang.reflect.Method.invoke(Method.java:511) 12-26 11:57:27.334: E/AndroidRuntime(5576): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:982) 12-26 11:57:27.334: E/AndroidRuntime(5576): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:749) 12-26 11:57:27.334: E/AndroidRuntime(5576): at dalvik.system.NativeStart.main(Native Method)

尝试使用Intent跳转至新Activity时程序停止运行

``` package com.level1.yukinoshita.swan0; import android.content.Intent; import android.os.Bundle; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.view.View; import android.support.design.widget.NavigationView; import android.support.v4.view.GravityCompat; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; import com.level1.yukinoshita.fragment.Fragment_autocharge; import com.level1.yukinoshita.fragment.Fragment_replyaction; import com.level1.yukinoshita.fragment.Fragment_searchall; import com.level1.yukinoshita.fragment.Fragment_socialaction; import com.level1.yukinoshita.fragment.Fragment_socialuser; import com.level1.yukinoshita.fragment.Fragment_userfavor; public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener { // private RecyclerView contentRecyclerView; // private List<String> recycleViewData; // private RecycleViewSimpleAdapter contentRecyclerViewAdapter; private static final int STACK=0; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setTitle(""); setSupportActionBar(toolbar); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Snackbar.make(view, "正在刷新", Snackbar.LENGTH_LONG) .setAction("Action", null).show(); } }); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); } @Override public void onBackPressed() { DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); if (drawer.isDrawerOpen(GravityCompat.START)) { drawer.closeDrawer(GravityCompat.START); } else { super.onBackPressed(); } } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @SuppressWarnings("StatementWithEmptyBody") @Override public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); if (id == R.id.nav_socialuser) { // 分配对应Fragment Fragment_socialuser fragment = new Fragment_socialuser(); getFragmentManager().beginTransaction().replace(R.id.main_contentview, fragment).commit(); } else if (id == R.id.nav_socialaction) { Fragment_socialaction fragment = new Fragment_socialaction(); getFragmentManager().beginTransaction().replace(R.id.main_contentview, fragment).commit(); } else if (id == R.id.nav_autocharge) { Fragment_autocharge fragment = new Fragment_autocharge(); getFragmentManager().beginTransaction().replace(R.id.main_contentview, fragment).commit(); } else if (id == R.id.nav_replyaction) { Fragment_replyaction fragment = new Fragment_replyaction(); getFragmentManager().beginTransaction().replace(R.id.main_contentview, fragment).commit(); } else if (id == R.id.nav_userfavor) { Fragment_userfavor fragment = new Fragment_userfavor(); getFragmentManager().beginTransaction().replace(R.id.main_contentview, fragment).commit(); } else if (id == R.id.nav_searchall) { Fragment_searchall fragment = new Fragment_searchall(); getFragmentManager().beginTransaction().replace(R.id.main_contentview, fragment).commit(); } else if (id == R.id.nav_settings) { // 使用Activity Intent intent = new Intent(this, Activity_settings.class); startActivity(intent); } else if (id == R.id.nav_developer) { // 使用Activity } DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; } } ``` 报错信息如下 04-15 01:34:22.769 6114-6114/com.level1.yukinoshita.swan0 E/AndroidRuntime: FATAL EXCEPTION: main Process: com.level1.yukinoshita.swan0, PID: 6114 android.content.ActivityNotFoundException: Unable to find explicit activity class {com.level1.yukinoshita.swan0/com.level1.yukinoshita.swan0.Activity_settings}; have you declared this activity in your AndroidManifest.xml? at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1794) at android.app.Instrumentation.execStartActivity(Instrumentation.java:1512) at android.app.Activity.startActivityForResult(Activity.java:3917) at android.app.Activity.startActivityForResult(Activity.java:3877) at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:842) at android.app.Activity.startActivity(Activity.java:4200) at android.app.Activity.startActivity(Activity.java:4168) at com.level1.yukinoshita.swan0.MainActivity.onNavigationItemSelected(MainActivity.java:125) at android.support.design.widget.NavigationView$1.onMenuItemSelected(NavigationView.java:151) at android.support.v7.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:811) at android.support.v7.view.menu.SubMenuBuilder.dispatchMenuItemSelected(SubMenuBuilder.java:84) at android.support.v7.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:152) at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:958) at android.support.design.internal.NavigationMenuPresenter$1.onClick(NavigationMenuPresenter.java:318) at android.view.View.performClick(View.java:5198) at android.view.View$PerformClick.run(View.java:21147) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 04-15 01:34:24.908 6114-6114/com.level1.yukinoshita.swan0 I/Process: Sending signal. PID: 6114 SIG: 9

关于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 更新UI 耗时问题

假如现在我得到了某个List<String>,里面有1000个字符串,然后我想我在主线程中按下某个Button之后,把它们都动态地加载到UI上来,完全是用代码动态添加的布局,然后执行的时候发现有点耗时。 现在有两个问题: 1.有没有什么机制可以让它加载地更快,因为发现更新UI的语句只能在主线程执行,但是耗时的本身就是这些语句 2.如果一定得耗时,我想在加载的时候显示一个progressDialog,更新UI语句全在主线程一个foreach()循环里,我在foreach前showDialog,在foreach后dismiss,发现似乎是没有效果,网上查到的使用方法都是子线程里发消息通知耗时操作完成了,我这种情况的话应该怎么办

Android5.0以上系统,从一个页面返回后白色背景会变灰色半透明,求解

接手一个别人写的项目,出现了这个问题虽然已经解决了但是不知道原理。 问题如下:MainActivity中有四个Fragment,进入登录页面再返回的时候,有两个Fragment白色背景会变成灰色,某些从MainActivity进入的二级页也会出现这个问题,我再那些背景变成灰色的页面onCreate的时候手动设置背景色为白色解决了,但是不知道这个问题到底是为什么出现的仅,限于5.0以上的系统才出现。求各位帮忙分析一下。下面是一个会变灰的页面的布局。 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/banner_detail_container" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/white" android:orientation="vertical"> <RelativeLayout android:layout_width="match_parent" android:layout_height="50dp" android:paddingLeft="10dp" > <Button android:id="@+id/back_banner_btn" android:layout_width="30dp" android:layout_height="30dp" android:background="@drawable/back" android:layout_centerVertical="true" android:onClick="onClick" /> <TextView android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_centerInParent="true" android:gravity="center_vertical" android:text="最新活动" android:textSize="18sp" android:textColor="@color/black" /> </RelativeLayout> <TextView android:layout_width="match_parent" android:layout_height="10dp" android:background="@color/darkline" /> <WebView android:id="@+id/webview_banner" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/white" /> </LinearLayout>

gridview无法更新啊,求教~~~~

package jx.jvtc.bestfoddServer; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import jx.jvtc.model.CustomerBuyFood; import jx.jvtc.model.FoodAndroid; import jx.jvtc.webserviceimpl.Orderbuyimpl; import android.R.integer; import android.app.ActionBar; import android.app.Activity; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.NavUtils; import android.view.Gravity; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.GridView; import android.widget.SimpleAdapter; import android.widget.TextView; import android.widget.Toast; public class SendMssion extends Activity { private GridView gridListView; private List<HashMap<String, Object>> data; private String test = "多列显示Test"; List<CustomerBuyFood> lsInfo; SimpleAdapter sa; public void showFoodInfo(List<FoodAndroid> lsFoodMenu, final int id) { String[] str = new String[lsFoodMenu.size()]; for (int i = 0; i < lsFoodMenu.size(); i++) { String value = lsFoodMenu.get(i).getMaterial(); value += " × "; value += lsFoodMenu.get(i).getId() + "份"; str[i] = value; } new AlertDialog.Builder(this).setTitle("需配送的菜").setItems(str, null) .setNegativeButton("正在派送", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub Thread a = new Thread(new Runnable() { @Override public void run() { // TODO Auto-generated method stub new Orderbuyimpl().updateorder(id, 0); lsInfo = new Orderbuyimpl() .getordertime(LoginState.cellPhone); data = new ArrayList<HashMap<String, Object>>(); for (int i = 0; i < lsInfo.size(); i++) { HashMap<String, Object> map = new HashMap<String, Object>(); map.put("sendStateStr", lsInfo.get(i) .getOflag()); System.out .println(lsInfo.get(i).getOflag()); data.add(map); } } }); a.start(); try { a.join(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } gridListView = (GridView) findViewById(R.id.list_gridView); sa = (SimpleAdapter) gridListView.getAdapter(); sa.notifyDataSetChanged(); // gridListView.setAdapter(sa); } }) .setPositiveButton("已送达", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub new Thread(new Runnable() { @Override public void run() { // TODO Auto-generated method stub new Orderbuyimpl().updateorder(id, 1); SendMssion.this.onResume(); } }).start(); } }).show(); } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Thread a = new Thread(new Runnable() { @Override public void run() { // TODO Auto-generated method stub lsInfo = new Orderbuyimpl().getordertime(LoginState.cellPhone); } }); a.start(); try { a.join(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (lsInfo.size() == 0) { setContentView(R.layout.activity_send_mission_null); } else { setContentView(R.layout.activity_send_mssion); gridListView = (GridView) findViewById(R.id.list_gridView); fillData(); sa = new SimpleAdapter(this, data, R.layout.activity_send_mission_item, new String[] { "phone", "address", "homeSendTime", "sendStateStr", "foodMenu", "id" }, new int[] { R.id.phone, R.id.sendAddr, R.id.sendTime, R.id.sendState }); gridListView.setAdapter(sa); gridListView .setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { // TODO Auto-generated method stub HashMap<String, Object> item = (HashMap<String, Object>) arg0 .getItemAtPosition(arg2); // setTitle((String) item.get("goods_text")); // String str = item.get("phone"); // Toast.makeText(SendMssion.this, "", // Toast.LENGTH_SHORT).show(); List<FoodAndroid> lsFoodMenu; lsFoodMenu = (List<FoodAndroid>) item .get("foodMenu"); // System.out.println(lsFoodMenu.size()+" ss"); int id = (Integer) item.get("id"); // System.out.println(id + "\tsendState"); showFoodInfo(lsFoodMenu, id); } }); } } public void fillData() { data = new ArrayList<HashMap<String, Object>>(); for (int i = 0; i < lsInfo.size(); i++) { HashMap<String, Object> map = new HashMap<String, Object>(); int id = lsInfo.get(i).getId(); map.put("phone", lsInfo.get(i).getPhone()); map.put("address", lsInfo.get(i).getAddress()); map.put("homeSendTime", lsInfo.get(i).getStrdate()); map.put("sendStateStr", lsInfo.get(i).getOflag()); map.put("id", id); map.put("foodMenu", lsInfo.get(i).getFoodmenu()); // System.out.println(String.valueOf(lsInfo.get(i).getId()) // + " \tDDDDDD"); data.add(map); } } }

《第一行代码》的酷欧天气,点开省列表以后显示的还是省,而不是城市,这是再点一下省就直接闪退

Logcat如下 FATAL EXCEPTION: main Process: com.coolweather.android, PID: 11807 java.lang.IndexOutOfBoundsException: Index: 6, Size: 0 at java.util.ArrayList.get(ArrayList.java:411) at com.coolweather.android.ChooseAreaFragment$1.onItemClick(ChooseAreaFragment.java:76) at android.widget.AdapterView.performItemClick(AdapterView.java:310) at android.widget.AbsListView.performItemClick(AbsListView.java:1165) at android.widget.AbsListView$PerformClick.run(AbsListView.java:3137) at android.widget.AbsListView$3.run(AbsListView.java:4052) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6290) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) 代码如下 package com.coolweather.android; import android.app.ProgressDialog; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; import com.coolweather.android.db.City; import com.coolweather.android.db.County; import com.coolweather.android.db.Province; import com.coolweather.android.util.HttpUtil; import com.coolweather.android.util.Utility; import org.litepal.crud.DataSupport; import java.io.IOException; import java.util.ArrayList; import java.util.List; import okhttp3.Call; import okhttp3.Callback; import okhttp3.Response; /** * Created by 王耀祖 on 2017/7/20. */ public class ChooseAreaFragment extends Fragment { public static final int LEVEL_PROVINCE = 0; public static final int LEVEL_CITY = 1; public static final int LEVEL_COUNTY = 2; private ProgressDialog progressDialog; private TextView titleText; private Button backButton; private ListView listView; private ArrayAdapter<String> adapter; private List<String> dataList = new ArrayList<>(); private List<Province> provinceList; private List<City> cityList; private List<County> countyList; private Province selectedProvince; private City selectedCity; private int currentLevel; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.choose_area, container, false); titleText = (TextView) view.findViewById(R.id.title_text); backButton = (Button) view.findViewById(R.id.back_button); listView = (ListView) view.findViewById(R.id.list_view); adapter = new ArrayAdapter<String>(getContext(), android.R.layout.simple_list_item_1, dataList); listView.setAdapter(adapter); return view; } @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (currentLevel == LEVEL_PROVINCE) { selectedProvince = provinceList.get(position); queryCities(); } else if (currentLevel == LEVEL_CITY) { selectedCity = cityList.get(position); queryCounties(); } } }); backButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if(currentLevel==LEVEL_COUNTY){ queryCities(); } else if(currentLevel==LEVEL_CITY){ queryProvinces(); } } }); queryProvinces(); } private void queryProvinces(){ titleText.setText("中国"); backButton.setVisibility(View.GONE); provinceList= DataSupport.findAll(Province.class); if(provinceList.size()>0){ dataList.clear(); for(Province province:provinceList) dataList.add(province.getProvinceName()); adapter.notifyDataSetChanged(); listView.setSelection(0); currentLevel=LEVEL_PROVINCE; } else{ String address="http://guolin.tech/api/china"; queryFromServer(address,"province"); } } private void queryCities(){ titleText.setText(selectedProvince.getProvinceName()); backButton.setVisibility(View.VISIBLE); cityList=DataSupport.where("provinceid = ?",String.valueOf(selectedProvince .getId())).find(City.class); if(cityList.size()>0) { cityList.clear(); for(City city:cityList) dataList.add(city.getCityName()); adapter.notifyDataSetChanged(); listView.setSelection(0); currentLevel=LEVEL_CITY; } else{ int provinceCode=selectedProvince.getProvinceCode(); String address="http://guolin.tech/api/china/"+provinceCode; queryFromServer(address,"city"); } } private void queryCounties(){ titleText.setText(selectedCity.getCityName()); backButton.setVisibility(View.VISIBLE); countyList=DataSupport.where("cityid = ?",String.valueOf(selectedCity .getId())).find(County.class); if(countyList.size()>0) { countyList.clear(); for(County county:countyList) dataList.add(county.getCountyName()); adapter.notifyDataSetChanged(); listView.setSelection(0); currentLevel=LEVEL_COUNTY; } else{ int provinceCode=selectedProvince.getProvinceCode(); int cityCode=selectedCity.getCityCode(); String address="http://guolin.tech/api/china/"+provinceCode+"/"+cityCode; queryFromServer(address,"county"); } } private void queryFromServer(String address,final String type){ showProgressDialog(); HttpUtil.sendOkHttpRequest(address, new Callback() { @Override public void onFailure(Call call, IOException e) { getActivity().runOnUiThread(new Runnable() { @Override public void run() { closeProgressDialog(); Toast.makeText(getContext(), "加载失败", Toast.LENGTH_SHORT).show(); } }); } @Override public void onResponse(Call call, Response response) throws IOException { String responseText=response.body().string(); boolean result=false; if("province".equals(type)) result= Utility.handleProvinceResponse(responseText); else if("city".equals(type)) result=Utility.handleCityResponse(responseText,selectedProvince.getId()); else if("county".equals(type)) result=Utility.handleCountyResponse(responseText,selectedCity.getId()); if(result){ getActivity().runOnUiThread(new Runnable() { @Override public void run() { closeProgressDialog(); if("province".equals(type)) queryProvinces(); else if("city".equals(type)) queryCities(); else if("county".equals(type)) queryCounties(); } }); } } }); } private void showProgressDialog(){ if(progressDialog==null){ progressDialog=new ProgressDialog(getActivity()); progressDialog.setMessage("正在加载。。。"); progressDialog.setCanceledOnTouchOutside(false); } progressDialog.show(); } private void closeProgressDialog(){ if(progressDialog!=null) progressDialog.dismiss(); } }

Android setLayoutParams()的问题

想知道在代码中通过getLayoutParams()得到一个View的LayoutParams,然后修改之后一定要通过set方法才能生效吗?比如修改了Width属性? 下面是学习的时候看到的代码,这个方法没有set啊,这是怎么回事呢 ``` @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initValues(); content.setOnTouchListener(this); } private void initValues() { WindowManager window = (WindowManager) getSystemService(Context.WINDOW_SERVICE); DisplayMetrics dm = new DisplayMetrics(); window.getDefaultDisplay().getMetrics(dm); screenWidth=dm.widthPixels; content = findViewById(R.id.content); menu = findViewById(R.id.menu); menuParams = (LinearLayout.LayoutParams) menu.getLayoutParams(); // 将menu的宽度设置为屏幕宽度减去menuPadding menuParams.width = screenWidth - menuPadding; // 左边缘的值赋值为menu宽度的负数 leftEdge = -menuParams.width; // menu的leftMargin设置为左边缘的值,这样初始化时menu就变为不可见 menuParams.leftMargin = leftEdge; // 将content的宽度设置为屏幕宽度 content.getLayoutParams().width = screenWidth; } ```

代码有错误,求大神帮忙指导!!!!

public class ContactsFragment extends Fragment implements OnClickListener { public static String hostIp; private ExpandableListView userList; private UserExpandableListAdapter adapter; private List<String> strGroups; //所有一级菜单名称集合 private List<List<User>> children; private TextView totalUser; private Button refreshButton; private TextView ipTextView;; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View contactsLayout = inflater.inflate(R.layout.contacts_layout, container, false); // return contactsLayout; if(!isWifiActive()){ //若wifi没有打开,提示 Toast.makeText(getActivity(), R.string.no_wifi, Toast.LENGTH_LONG).show(); } findViews(); strGroups = new ArrayList<String>(); //所有一级菜单名称集合 children = new ArrayList<List<User>>(); // netThreadHelper = NetThreadHelper.newInstance(); BaseFragment.netThreadHelper.connectSocket(); //开始监听数据 BaseFragment.netThreadHelper.noticeOnline(); //广播上线 adapter = new UserExpandableListAdapter(getActivity(), strGroups, children); userList.setAdapter(adapter); refreshButton.setOnClickListener(this); refreshViews(); return contactsLayout; } @Override public void finish() { // TODO Auto-generated method stub super.finish(); BaseFragment.netThreadHelper.noticeOffline(); //通知下线 BaseFragment.netThreadHelper.disconnectSocket(); //停止监听 } public void onViewCreated(View view, Bundle savedInstanceState) { // TODO Auto-generated method stub super.onViewCreated(view, savedInstanceState); totalUser =(TextView)view.findViewById(R.id.totalUser); userList = (ExpandableListView)view.findViewById(R.id.userlist); refreshButton = (Button) view.findViewById(R.id.refresh); ipTextView = (TextView) view.findViewById(R.id.mymood); hostIp = getLocalIpAddress(); ipTextView.setText(hostIp); //设置IP } @Override public void processMessage(Message msg) { // TODO Auto-generated method stub switch(msg.what){ case IpMessageConst.IPMSG_BR_ENTRY: case IpMessageConst.IPMSG_BR_EXIT: case IpMessageConst.IPMSG_ANSENTRY: case IpMessageConst.IPMSG_SENDMSG: refreshViews(); break; } } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { // TODO Auto-generated method stub if (keyCode == KeyEvent.KEYCODE_BACK) exit(); return true; } //更新数据和UI显示 private void refreshViews(){ //清空数据 strGroups.clear(); children.clear(); Map<String,User> currentUsers = new HashMap<String, User>(); currentUsers.putAll(BaseFragment.netThreadHelper.getUsers()); Queue<ChatMessage> msgQueue = BaseFragment.netThreadHelper.getReceiveMsgQueue(); Map<String, Integer> ip2Msg = new HashMap<String, Integer>(); //IP地址与未收消息个数的map //遍历消息队列,填充ip2Msg Iterator<ChatMessage> it = msgQueue.iterator(); while(it.hasNext()){ ChatMessage chatMsg = it.next(); String ip = chatMsg.getSenderIp(); //得到消息发送者IP Integer tempInt = ip2Msg.get(ip); if(tempInt == null){ //若map中没有IP对应的消息个数,则把IP添加进去,值为1 ip2Msg.put(ip, 1); }else{ //若已经有对应ip,则将其值加一 ip2Msg.put(ip, ip2Msg.get(ip)+1); } } //遍历currentUsers,更新strGroups和children Iterator<String> iterator = currentUsers.keySet().iterator(); while (iterator.hasNext()) { User user = currentUsers.get(iterator.next()); //设置每个在线用户对应的未收消息个数 if(ip2Msg.get(user.getIp()) == null){ user.setMsgCount(0); }else{ user.setMsgCount(ip2Msg.get(user.getIp())); } String groupName = user.getGroupName(); int index = strGroups.indexOf(groupName); if(index == -1){ //没有相应分组,则添加分组,并添加对应child strGroups.add(groupName); // List<Map<String,String>> childData = new ArrayList<Map<String,String>>(); // Map<String, String> child = new HashMap<String,String>(); // child.put("userName", user.getUserName()); // childData.add(child); // children.add(childData); List<User> childData = new ArrayList<User>(); childData.add(user); children.add(childData); }else{ //已存在分组,则将对应child添加到相对应分组中 // Map<String,String> child = new HashMap<String,String>(); // child.put("userName", user.getUserName()); // children.get(index).add(child); children.get(index).add(user); } } //更新groups // for(int i = 0; i < strGroups.size(); i++){ // Map<String,String> groupMap = new HashMap<String,String>(); // groupMap.put("group", strGroups.get(i)); // groups.add(groupMap); // } adapter.notifyDataSetChanged(); //更新ExpandableListView String countStr = "当前在线" + currentUsers.size() +"个用户"; totalUser.setText(countStr); //更新TextView } @Override public void onClick(View v) { // TODO Auto-generated method stub if(v.equals(refreshButton)){ //若是刷新 BaseFragment.netThreadHelper.refreshUsers(); refreshViews(); } } //判断wifi是否打开 public boolean isWifiActive(){ ConnectivityManager mConnectivity = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); if(mConnectivity != null){ NetworkInfo[] infos = mConnectivity.getAllNetworkInfo(); if(infos != null){ for(NetworkInfo ni: infos){ if("WIFI".equals(ni.getTypeName()) && ni.isConnected()) return true; } } } return false; } //得到本机IP地址 public String getLocalIpAddress(){ try{ Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); while(en.hasMoreElements()){ NetworkInterface nif = en.nextElement(); Enumeration<InetAddress> enumIpAddr = nif.getInetAddresses(); while(enumIpAddr.hasMoreElements()){ InetAddress mInetAddress = enumIpAddr.nextElement(); if(!mInetAddress.isLoopbackAddress() && InetAddressUtils.isIPv4Address(mInetAddress.getHostAddress())){ return mInetAddress.getHostAddress().toString(); } } } }catch(SocketException ex){ Log.e("MyFeiGeActivity", "获取本地IP地址失败"); } return null; } //获取本机MAC地址 public String getLocalMacAddress(){ WifiManager wifi = (WifiManager)getSystemService(Context.WIFI_SERVICE); WifiInfo info = wifi.getConnectionInfo(); return info.getMacAddress(); } } ![图片说明](https://img-ask.csdn.net/upload/201605/12/1463066299_353280.png) 求大神指点迷津!!!

代码有错误,求大神帮忙指点迷津!!!!

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) 求大神指点

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

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

Vue + Spring Boot 项目实战(十九):Web 项目优化解决方案

快来一起探索如何打脸我们的破项目,兄弟姐妹们把害怕打在公屏上!

你连存活到JDK8中著名的Bug都不知道,我怎么敢给你加薪

CopyOnWriteArrayList.java和ArrayList.java,这2个类的构造函数,注释中有一句话 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 public ArrayList(Collection&lt;? ...

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

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

CSDN:因博主近期注重写专栏文章(已超过150篇),订阅博主专栏人数在突增,近期很有可能提高专栏价格(已订阅的不受影响),提前声明,敬请理解!

CSDN:因博主近期注重写专栏文章(已超过150篇),订阅博主专栏人数在突增,近期很有可能提高专栏价格(已订阅的不受影响),提前声明,敬请理解! 目录 博客声明 大数据了解博主粉丝 博主的粉丝群体画像 粉丝群体性别比例、年龄分布 粉丝群体学历分布、职业分布、行业分布 国内、国外粉丝群体地域分布 博主的近期访问每日增量、粉丝每日增量 博客声明 因近期博主写专栏的文章越来越多,也越来越精细,逐步优化文章。因此,最近一段时间,订阅博主专栏的人数增长也非常快,并且专栏价

一个HashMap跟面试官扯了半个小时

一个HashMap能跟面试官扯上半个小时 关注 安琪拉的博客 1.回复面试领取面试资料 2.回复书籍领取技术电子书 3.回复交流领取技术电子书 前言 HashMap应该算是Java后端工程师面试的必问题,因为其中的知识点太多,很适合用来考察面试者的Java基础。 开场 面试官: 你先自我介绍一下吧! 安琪拉: 我是安琪拉,草丛三婊之一,最强中单(钟馗不服)!哦,不对,串场了,我是**,目...

我说我不会算法,阿里把我挂了。

不说了,字节跳动也反手把我挂了。

记录下入职中软一个月(外包华为)

我在年前从上一家公司离职,没想到过年期间疫情爆发,我也被困在家里,在家呆着的日子让人很焦躁,于是我疯狂的投简历,看面试题,希望可以进大公司去看看。 我也有幸面试了我觉得还挺大的公司的(虽然不是bat之类的大厂,但是作为一名二本计算机专业刚毕业的大学生bat那些大厂我连投简历的勇气都没有),最后选择了中软,我知道这是一家外包公司,待遇各方面甚至不如我的上一家公司,但是对我而言这可是外包华为,能...

面试:第十六章:Java中级开发

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

培训班出来的人后来都怎么样了?(二)

接着上回说,培训班学习生涯结束了。后面每天就是无休止的背面试题,不是没有头脑的背,培训公司还是有方法的,现在回想当时背的面试题好像都用上了,也被问到了。回头找找面试题,当时都是打印下来天天看,天天背。 不理解呢也要背,面试造飞机,上班拧螺丝。班里的同学开始四处投简历面试了,很快就有面试成功的,刚开始一个,然后越来越多。不知道是什么原因,尝到胜利果实的童鞋,不满足于自己通过的公司,嫌薪水要少了,选择...

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

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

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

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

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

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

工作八年,月薪60K,裸辞两个月,投简历投到怀疑人生!

近日,有网友在某职场社交平台吐槽,自己裸辞两个月了,但是找工作却让自己的心态都要崩溃了,全部无果,不是已查看无回音,就是已查看不符合。 “工作八年,两年一跳,裸辞两个月了,之前月薪60K,最近找工作找的心态崩了!所有招聘工具都用了,全部无果,不是已查看无回音,就是已查看不符合。进头条,滴滴之类的大厂很难吗???!!!投简历投的开始怀疑人生了!希望 可以收到大厂offer” 先来看看网...

大牛都会用的IDEA调试技巧!!!

导读 前天面试了一个985高校的实习生,问了他平时用什么开发工具,他想也没想的说IDEA,于是我抛砖引玉的问了一下IDEA的调试用过吧,你说说怎么设置断点...

都前后端分离了,咱就别做页面跳转了!统统 JSON 交互

文章目录1. 无状态登录1.1 什么是有状态1.2 什么是无状态1.3 如何实现无状态1.4 各自优缺点2. 登录交互2.1 前后端分离的数据交互2.2 登录成功2.3 登录失败3. 未认证处理方案4. 注销登录 这是本系列的第四篇,有小伙伴找不到之前文章,松哥给大家列一个索引出来: 挖一个大坑,Spring Security 开搞! 松哥手把手带你入门 Spring Security,别再问密...

97年世界黑客编程大赛冠军作品(大小仅为16KB),惊艳世界的编程巨作

这是世界编程大赛第一名作品(97年Mekka ’97 4K Intro比赛)汇编语言所写。 整个文件只有4095个字节, 大小仅仅为16KB! 不仅实现了3D动画的效果!还有一段震撼人心的背景音乐!!! 内容无法以言语形容,实在太强大! 下面是代码,具体操作看最后! @echo off more +1 %~s0|debug e100 33 f6 bf 0 20 b5 10 f3 a5...

程序员是做全栈工程师好?还是专注一个领域好?

昨天,有位大一的同学私信我,说他要做全栈工程师。 我一听,这不害了孩子么,必须制止啊。 谁知,讲到最后,更确定了他做全栈程序员的梦想。 但凡做全栈工程师的,要么很惨,要么很牛! 但凡很牛的,绝不是一开始就是做全栈的! 全栈工程师听起来好听,但绝没有你想象的那么简单。 今天听我来给你唠,记得帮我点赞哦。 一、全栈工程师的职责 如果你学习编程的目的只是玩玩,那随意,想怎么学怎么学。...

不要再到处使用 === 了

我们知道现在的开发人员都使用 === 来代替 ==,为什么呢?我在网上看到的大多数教程都认为,要预测 JavaScript 强制转换是如何工作这太复杂了,因此建议总是使用===。这些都...

什么是a站、b站、c站、d站、e站、f站、g站、h站、i站、j站、k站、l站、m站、n站?00后的世界我不懂!

A站 AcFun弹幕视频网,简称“A站”,成立于2007年6月,取意于Anime Comic Fun,是中国大陆第一家弹幕视频网站。A站以视频为载体,逐步发展出基于原生内容二次创作的完整生态,拥有高质量互动弹幕,是中国弹幕文化的发源地;拥有大量超粘性的用户群体,产生输出了金坷垃、鬼畜全明星、我的滑板鞋、小苹果等大量网络流行文化,也是中国二次元文化的发源地。 B站 全称“哔哩哔哩(bilibili...

十个摸鱼,哦,不对,是炫酷(可以玩一整天)的网站!!!

文章目录前言正文**1、Kaspersky Cyberthreat real-time map****2、Finding Home****3、Silk – Interactive Generative Art****4、Liquid Particles 3D****5、WINDOWS93****6、Staggering Beauty****7、Ostagram图片生成器网址****8、全历史网址*...

终于,月薪过5万了!

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

用了这个 IDE 插件,5分钟解决前后端联调!

点击上方蓝色“程序猿DD”,选择“设为星标”回复“资源”获取独家整理的学习资料!作者 |李海庆我是一个 Web 开发前端工程师,受到疫情影响,今天是我在家办公的第78天。开发了两周,...

大厂的 404 页面都长啥样?最后一个笑了...

每天浏览各大网站,难免会碰到404页面啊。你注意过404页面么?猿妹搜罗来了下面这些知名网站的404页面,以供大家欣赏,看看哪个网站更有创意: 正在上传…重新上传取消 腾讯 正在上传…重新上传取消 网易 淘宝 百度 新浪微博 正在上传…重新上传取消 新浪 京东 优酷 腾讯视频 搜...

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

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

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

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

Java14 新特性解读

Java14 已于 2020 年 3 月 17 号发布,官方特性解读在这里:https://openjdk.java.net/projects/jdk/14/以下是个人对于特性的中文式...

前端还能这么玩?(女朋友生日,用前端写了一个好玩的送给了她,高兴坏了)

前端还能这么玩?(女朋友生日,用前端写了一个好玩的送给了她,高兴坏了)

爬虫(101)爬点重口味的

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

工作两年简历写成这样,谁要你呀!

作者:小傅哥 博客:https://bugstack.cn 沉淀、分享、成长,让自己和他人都能有所收获! 一、前言 最近有伙伴问小傅哥,我的简历怎么投递了都没有反应,心里慌的很呀。 工作两年了目前的公司没有什么大项目,整天的维护别人的代码,有坑也不让重构,都烦死了。荒废我一身技能无处施展,投递的简历也没人看。我是不动物园里的猩猩,狒狒了! 我要加班,我要996,我要疯狂编码,求给我个机会… ...

相关热词 c# 开发接口 c# 中方法上面的限制 c# java 时间戳 c#单元测试入门 c# 数组转化成文本 c#实体类主外键关系设置 c# 子函数 局部 c#窗口位置设置 c# list 查询 c# 事件 执行顺序
立即提问
相关内容推荐