安卓bottom navigation + Fragment +Listview 显示数据,有时显示不出来

androidStudio 直接创建一个带有bottom navigation 的活动
然后在监听器里用replace切换fragment(一共有三个fragment对应navigation)fragment的onAttach访问tomcat获取数据 onCreateView方法将数据绑定在fragment的 listview上。有时运行可以直接显示数据,有时首页一片空白,点击navigation切换碎片再切换回首页,首页的listview才显示数据。

3个回答

你看一下每一个fragment的visibility属性,,大部分时候你要手动设置某一个fragment可见,其他隐藏,否则会出现层叠现象。。最后添加的fragment遮挡住第一层的fragment

可以吧你的面板配置文件贴出来看看么,估计是这的问题

个人想法:刚看到你这个问题,我想到两种可能的原因。
1、你是不是没有设置项目刚运行时手动设置显示第一个fragment呢,你不设置的话它肯定不会出来,还有有时候你运行程序能显示出来
可能是因为你没有杀掉缓存进程啊。
2、如果确定代码没问题,那就只能是网络问题了,建议你加一个progressbar看看是不是因为网速太慢的问题。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
安卓bottom navigation + Fragment +Listview 显示数据,有时显示不出来
androidStudio 直接创建一个带有bottom navigation 的活动 然后在监听器里用replace切换fragment(一共有三个fragment对应navigation)fragment的onAttach访问tomcat获取数据 onCreateView方法将数据绑定在fragment的 listview上。有时运行可以直接显示数据,有时首页一片空白,点击navigation切换碎片再切换回首页,首页的listview才显示数据。
麻烦各位大神帮帮忙!!!Fragment的ListView不能显示
``` public class HistoryFragment extends Fragment { // TODO: Rename parameter arguments, choose names that match // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER private static final String ARG_PARAM1 = "param1"; private static final String ARG_PARAM2 = "param2"; // TODO: Rename and change types of parameters private String mParam1; private String mParam2; ListView listView; private OnFragmentInteractionListener mListener; public HistoryFragment() { // Required empty public constructor } public static HistoryFragment newInstance(String param1, String param2) { HistoryFragment fragment = new HistoryFragment(); Bundle args = new Bundle(); args.putString(ARG_PARAM1, param1); args.putString(ARG_PARAM2, param2); fragment.setArguments(args); return fragment; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getArguments() != null) { mParam1 = getArguments().getString(ARG_PARAM1); mParam2 = getArguments().getString(ARG_PARAM2); } } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment // return inflater.inflate(R.layout.fragment_history, container, false); String[] locations = {"广州市番禺区1", "广州市天河区2", "广州市海珠区3", "广州市越秀区4", "广州市南沙区5", "广州市佛山区6", "广州市番禺区7", "广州市天河区8", "广州市佛山区9", "广州市海珠区0", "广州市越秀区11", "广州市南沙区12", "广州市佛山区13", "广州市番禺区14", "广州市天河区15", "广州市海珠区16", "广州市越秀区17", "广州市南沙区18", "广州市中山大道19"}; List<Map<String, Object>> items = new ArrayList<Map<String,Object>>(); View view = inflater.inflate(R.layout.fragment_history,null); listView = view.findViewById(R.id.history_listview); Map<String, Object> item = new HashMap<String, Object>(); for(int i=0;i < locations.length;i++) { item.put("location", locations[i]); items.add(item); } SimpleAdapter simpleAdapter = new SimpleAdapter(getActivity(),items, R.layout.history_list_item,new String[]{"locations"},new int[]{R.id.history_location}); listView.setAdapter(simpleAdapter); // listView.setAdapter(new ArrayAdapter<>(view.getContext(), R.layout.history_list_item,locations)); return view; } // TODO: Rename method, update argument and hook method into UI event public void onButtonPressed(Uri uri) { if (mListener != null) { mListener.onFragmentInteraction(uri); } } @Override public void onAttach(Context context) { super.onAttach(context); if (context instanceof OnFragmentInteractionListener) { mListener = (OnFragmentInteractionListener) context; } else { throw new RuntimeException(context.toString() + " must implement OnFragmentInteractionListener"); } } @Override public void onDetach() { super.onDetach(); mListener = null; } public interface OnFragmentInteractionListener { // TODO: Update argument type and name void onFragmentInteraction(Uri uri); } } ---------------------------------------------------------------------------- public class MainActivity extends AppCompatActivity implements MapFragment.OnFragmentInteractionListener, HistoryFragment.OnFragmentInteractionListener,SettingsFragment.OnFragmentInteractionListener{ // private TextView mTextMessage; private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener = new BottomNavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); Fragment fragment; switch (item.getItemId()) { case R.id.navigation_map: // mTextMessage.setText(R.string.title_map); fragment = MapFragment.newInstance("",""); fragmentTransaction.replace(R.id.content,fragment); fragmentTransaction.commit(); return true; case R.id.navigation_history: fragment = HistoryFragment.newInstance("",""); fragmentTransaction.replace(R.id.content,fragment); fragmentTransaction.commit(); // mTextMessage.setText(R.string.title_history); return true; case R.id.navigation_settings: fragment = SettingsFragment.newInstance("",""); fragmentTransaction.replace(R.id.content,fragment); fragmentTransaction.commit(); // mTextMessage.setText(R.string.title_settings); return true; } return false; } }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); Fragment fragment; fragment = MapFragment.newInstance("",""); fragmentTransaction.replace(R.id.content,fragment); fragmentTransaction.commit(); // mTextMessage = (TextView) findViewById(R.id.message); BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation); navigation.setItemIconTintList(null); // navigation.setSelectedItemId(R.id.navigation_map); navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener); } @Override public void onFragmentInteraction(Uri uri) { } } ``` ------------------------------------------ 运行结果: ![图片说明](https://img-ask.csdn.net/upload/201710/09/1507482366_513297.png) Fragment 的layout文件 ``` <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.hp.fragment.HistoryFragment"> <!-- TODO: Update blank fragment layout --> <!--<TextView--> <!--android:layout_width="match_parent"--> <!--android:layout_height="match_parent"--> <!--android:text="@string/hello_history_fragment" />--> <ListView android:id="@+id/history_listview" android:layout_width="match_parent" android:layout_height="wrap_content"/> </FrameLayout> ``` list item layout文件 ``` <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:id="@+id/history_location" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" /> </LinearLayout> ``` main activity layout 文件 ``` <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <FrameLayout android:id="@+id/content" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1"> <!--<TextView--> <!--android:id="@+id/message"--> <!--android:layout_width="match_parent"--> <!--android:layout_height="wrap_content"--> <!--android:layout_marginBottom="@dimen/activity_vertical_margin"--> <!--android:layout_marginLeft="@dimen/activity_horizontal_margin"--> <!--android:layout_marginRight="@dimen/activity_horizontal_margin"--> <!--android:layout_marginTop="@dimen/activity_vertical_margin"--> <!--android:text="@string/title_map" />--> </FrameLayout> <android.support.design.widget.BottomNavigationView android:id="@+id/navigation" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" android:background="?android:attr/windowBackground" app:menu="@menu/navigation" /> </LinearLayout> ```
Fragment tab 内容不能显示
我使用俩个 fragments 创建了程序。这俩个 fragment 可以互相切换。代码编译和运行都没有问题,俩个 tabs 都能显示出来,也可以互相切换,但是 tabs 没有内容。我觉得是 fragments 的问题,然后设置 setcontentview。为什么 HoloEverywhere 和ActionbarSherlock 里 tab 的内容显示不出来? main activity: import java.util.ArrayList; import org.holoeverywhere.app.Activity; import org.holoeverywhere.widget.TextView; import com.actionbarsherlock.app.ActionBar; import com.actionbarsherlock.app.ActionBar.Tab; import com.actionbarsherlock.app.SherlockActivity; import android.content.Context; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.app.FragmentTransaction; import android.support.v4.view.ViewPager; import android.view.WindowManager; public class SwipeTabsMainActivity extends Activity { ViewPager mViewPager; TabsAdapter mTabsAdapter; TextView tabCenter; TextView tabText; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); mViewPager = new ViewPager(this); mViewPager.setId(R.id.pager); setContentView(mViewPager); ActionBar bar = getSupportActionBar(); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE); mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(bar.newTab().setText("Stopwatch"),StopWatchFragment.class, null); mTabsAdapter.addTab(bar.newTab().setText("Timer"), CountdownFragment.class, null); } public static class TabsAdapter extends FragmentPagerAdapter implements ActionBar.TabListener, ViewPager.OnPageChangeListener { private final Context mContext; private final ActionBar mActionBar; private final ViewPager mViewPager; private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>(); static final class TabInfo { private final Class<?> clss; private final Bundle args; TabInfo(Class<?> _class, Bundle _args) { clss = _class; args = _args; } } public TabsAdapter(Activity activity, ViewPager pager) { super(activity.getSupportFragmentManager()); mContext = activity; mActionBar = activity.getSupportActionBar(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } public void addTab(ActionBar.Tab tab, Class<?> clss, Bundle args) { TabInfo info = new TabInfo(clss, args); tab.setTag(info); tab.setTabListener(this); mTabs.add(info); mActionBar.addTab(tab); notifyDataSetChanged(); } @Override public int getCount() { return mTabs.size(); } @Override public Fragment getItem(int position) { TabInfo info = mTabs.get(position); return Fragment.instantiate(mContext, info.clss.getName(), info.args); } @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int position) { mActionBar.setSelectedNavigationItem(position); } @Override public void onPageScrollStateChanged(int state) { } @Override public void onTabSelected(Tab tab, FragmentTransaction ft) { Object tag = tab.getTag(); for (int i = 0; i < mTabs.size(); i++) { if (mTabs.get(i) == tag) { mViewPager.setCurrentItem(i); } } } @Override public void onTabUnselected(Tab tab, FragmentTransaction ft) { } @Override public void onTabReselected(Tab tab, FragmentTransaction ft) { } } } Main Activity's xml <?xml version="1.0" encoding="utf-8"?> <android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/pager" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" />
android 错误: 不兼容的类型: ImageFragment无法转换为Fragment
package com.example.actionbar; import android.app.ActionBar; import android.app.Activity; import android.app.FragmentTransaction; import android.os.Bundle; import android.support.v4.app.Fragment; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final ActionBar actionBar =getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayShowTitleEnabled(false); TextFragment aFragment =new TextFragment(); ActionBar.Tab tab1=actionBar.newTab(); tab1.setText("文字"); tab1.setIcon(R.drawable.ic_launcher_foreground); tab1.setTabListener(new ListenerA(aFragment)); actionBar.addTab(tab1); ImageFragment bFragment = new ImageFragment(); ActionBar.Tab tab2 = actionBar.newTab(); tab2.setText("图片"); tab2.setTabListener(new Listenerb(bFragment)); actionBar.addTab(tab2); } private class ListenerA implements ActionBar.TabListener { private TextFragment mFragemnt; public ListenerA(TextFragment fragment) { mFragemnt =fragment; } @Override public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) { ft.add(R.id.fragment_content, mFragemnt, null); } //mFragemnt 这出错 下面的也爆红 @Override public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) { ft.remove(mFragemnt); } @Override public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) { } } private class Listenerb implements ActionBar.TabListener { private ImageFragment ImFragment; public Listenerb(ImageFragment fragment) { ImFragment =fragment ; } public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) { ft.add(R.id.fragment_content, ImFragment, null); } //ImFragment 这出错 下面的也爆红 public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) { ft.remove(ImFragment); } @Override public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) { } } }
Robot Navigation 罗伯特的导航问题
Problem Description A robot has been sent to explore a remote planet. To specify a path the robot should take, a program is sent each day. The program consists of a sequence of the following commands: FORWARD X: move forward by X units. TURN LEFT: turn left (in place) by 90 degrees. TURN RIGHT: turn right (in place) by 90 degrees. The robot also has sensor units which allow it to obtain a map of its surrounding area. The map is represented as a grid. Some grid points contain hazards (e.g. craters) and the program must avoid these points or risk losing the robot. Naturally, if the initial location of the robot, the direction it is facing, and its destination position are known, it is best to send the shortest program (one consisting of the fewest commands) to move the robot to its destination (we do not care which direction it faces at the destination). You are more interested in knowing the number of different shortest programs that can move the robot to its destination. However, the number of shortest programs can be very large, so you are satisfied to compute the number as a remainder modulo 1,000,000. Input There will be several test cases in the input. Each test case will begin with a line with two integers N M Where N is the number of rows in the grid, and M is the number of columns in the grid (2 ≤ N, M ≤ 100). The next N lines of input will have M characters each. The characters will be one of the following: ‘.’ Indicating a navigable grid point. ‘*’ Indicating a crater (i.e. a non-navigable grid point). ‘X’ Indicating the target grid point. There will be exactly one ‘X’. ‘N’, ‘E’, ‘S’, or ‘W’ Indicating the starting point and initial heading of the robot. There will be exactly one of these. Note that the directions mirror compass directions on a map: N is North (toward the top of the grid), E is East (toward the right of the grid), S is South (toward the bottom of the grid) and W is West (toward the left of the grid). There will be no spaces and no other characters in the description of the map. The input will end with a line with two 0s. Output For each test case, output two integers on a single line, with a single space between them. The first is the length of a shortest possible program to navigate the robot from its starting point to the target, and the second is the number of different programs of that length which will get the robot to the target (modulo 1,000,000). If there is no path from the robot to the target, output two zeros separated by a single space. Output no extra spaces, and do not separate answers with blank lines. Sample Input 5 6 *....X .....* .....* .....* N....* 6 5 ....X .**** .**** .**** .**** N**** 3 3 .E. *** .X. 0 0 Sample Output 6 4 3 1 0 0
Robot Navigation 编写思路
Problem Description A robot has been sent to explore a remote planet. To specify a path the robot should take, a program is sent each day. The program consists of a sequence of the following commands: FORWARD X: move forward by X units. TURN LEFT: turn left (in place) by 90 degrees. TURN RIGHT: turn right (in place) by 90 degrees. The robot also has sensor units which allow it to obtain a map of its surrounding area. The map is represented as a grid. Some grid points contain hazards (e.g. craters) and the program must avoid these points or risk losing the robot. Naturally, if the initial location of the robot, the direction it is facing, and its destination position are known, it is best to send the shortest program (one consisting of the fewest commands) to move the robot to its destination (we do not care which direction it faces at the destination). You are more interested in knowing the number of different shortest programs that can move the robot to its destination. However, the number of shortest programs can be very large, so you are satisfied to compute the number as a remainder modulo 1,000,000. Input There will be several test cases in the input. Each test case will begin with a line with two integers N M Where N is the number of rows in the grid, and M is the number of columns in the grid (2 ≤ N, M ≤ 100). The next N lines of input will have M characters each. The characters will be one of the following: ‘.’ Indicating a navigable grid point. ‘*’ Indicating a crater (i.e. a non-navigable grid point). ‘X’ Indicating the target grid point. There will be exactly one ‘X’. ‘N’, ‘E’, ‘S’, or ‘W’ Indicating the starting point and initial heading of the robot. There will be exactly one of these. Note that the directions mirror compass directions on a map: N is North (toward the top of the grid), E is East (toward the right of the grid), S is South (toward the bottom of the grid) and W is West (toward the left of the grid). There will be no spaces and no other characters in the description of the map. The input will end with a line with two 0s. Output For each test case, output two integers on a single line, with a single space between them. The first is the length of a shortest possible program to navigate the robot from its starting point to the target, and the second is the number of different programs of that length which will get the robot to the target (modulo 1,000,000). If there is no path from the robot to the target, output two zeros separated by a single space. Output no extra spaces, and do not separate answers with blank lines. Sample Input 5 6 *....X .....* .....* .....* N....* 6 5 ....X .**** .**** .**** .**** N**** 3 3 .E. *** .X. 0 0 Sample Output 6 4 3 1 0 0
請問 Fragment 在add和hide時為甚麼報錯?
如題我在製作導覽列時, add和hide不給我放我new的fragment,實在想不出原因, 請各位大大告訴我 ``` package com.example.test; import android.app.FragmentTransaction; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.design.widget.BottomNavigationView; import android.support.v7.app.AppCompatActivity; import android.view.MenuItem; import android.widget.TextView; import com.example.test.home_Fragment; import com.example.test.live_fragment; import com.example.test.car_fragment; import com.example.test.notify_fragment; import com.example.test.set_fragment; public class MainActivity extends AppCompatActivity { private TextView mTextMessage; private home_Fragment homef; private live_fragment livef; private car_fragment carf; private notify_fragment notifyf; private set_fragment setf; private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener = new BottomNavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { switch (item.getItemId()) { case R.id.navigation_home: mTextMessage.setText(R.string.title_home); return true; case R.id.navigation_live: mTextMessage.setText("live"); return true; case R.id.navigation_car: mTextMessage.setText("car"); return true; case R.id.navigation_notifications: mTextMessage.setText("notification"); return true; case R.id.navigation_setting: mTextMessage.setText("setting"); return true; } return false; } }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initial(); mTextMessage = (TextView) findViewById(R.id.message); BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation); navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener); } //初始化fragment private void initial() { homef = new home_Fragment(); carf = new car_fragment(); livef = new live_fragment(); notifyf = new notify_fragment(); setf = new set_fragment(); FragmentTransaction itfragment = getFragmentManager().beginTransaction(); itfragment.add(R.id.content,homef).add(R.id.content,carf).add(R.id.content,livef).add(R.id.content,notifyf) .add(R.id.content,setf); itfragment.hide(homef).hide(carf).hide(livef);//隐藏fragment itfragment.addToBackStack(null); itfragment.commit(); } } ``` ![图片说明](https://img-ask.csdn.net/upload/201903/15/1552642887_533675.png) ![图片说明](https://img-ask.csdn.net/upload/201903/15/1552643038_835445.png)
請問 Fragment add 使用 R.id.content 為甚麼報錯?
實在不懂哪裡錯了? 使用buttom navigation想做出導覽列切換fragment 但是R.id.content 卻不給用。 後面hide也是報錯。 請各位大大跟我說明 ``` package com.example.test; import android.app.FragmentTransaction; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.design.widget.BottomNavigationView; import android.support.v7.app.AppCompatActivity; import android.view.MenuItem; import android.widget.TextView; import com.example.test.home_Fragment; import com.example.test.live_fragment; import com.example.test.car_fragment; import com.example.test.notify_fragment; import com.example.test.set_fragment; public class MainActivity extends AppCompatActivity { private TextView mTextMessage; private home_Fragment homef; private live_fragment livef; private car_fragment carf; private notify_fragment notifyf; private set_fragment setf; private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener = new BottomNavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { switch (item.getItemId()) { case R.id.navigation_home: mTextMessage.setText(R.string.title_home); return true; case R.id.navigation_live: mTextMessage.setText("live"); return true; case R.id.navigation_car: mTextMessage.setText("car"); return true; case R.id.navigation_notifications: mTextMessage.setText("notification"); return true; case R.id.navigation_setting: mTextMessage.setText("setting"); return true; } return false; } }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initial(); mTextMessage = (TextView) findViewById(R.id.message); BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation); navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener); } //初始化fragment private void initial() { homef = new home_Fragment(); carf = new car_fragment(); livef = new live_fragment(); notifyf = new notify_fragment(); setf = new set_fragment(); FragmentTransaction itfragment = getFragmentManager().beginTransaction(); itfragment.add(R.id.content,homef).add(R.id.content,carf).add(R.id.content,livef).add(R.id.content,notifyf) .add(R.id.content,setf); itfragment.hide(homef).hide(carf).hide(livef);//隐藏fragment itfragment.addToBackStack(null); itfragment.commit(); } } ``` ![图片说明](https://img-ask.csdn.net/upload/201903/15/1552587769_658803.png) ![图片说明](https://img-ask.csdn.net/upload/201903/15/1552588264_246627.png)
Android Navigation View
Item可以根据权限禁止点击吗, 请问该如何实现 看了官方文档,好像并没有提供這类方法
Android Studio中如何实现Navigation View中的页面切换?
![图片说明](https://img-ask.csdn.net/upload/201907/19/1563504527_147519.jpg) 我想实现在NavigationView中的按钮点击页面切换,我按照如图方式给给Navigation中的item写了点击事件,可是app在虚拟机上跑的时候点击对应按钮就会闪退。想请问一下这是为什么呀。
Android如何隐藏navigation bar
android 8.0 我需要在一个界面想要隐藏navigationbar(statusbar显示),并且在该界面永远生效,需要怎么操作? 网上找了一些代码设置getWindwo().setSystemuiVisible(........);但都不能达到效果
为什么我的eclipse中android activity没有Navigation Drawer
为什么我的eclipse中android activity没有Navigation Drawer Activity。。是ADT版本太低了,还是api的版本太低了。。
在android studio中新建Navigation Drawer把侧边栏做成登陆界面
安卓新建项目Navigation Drawer的侧边栏包括一个layout的nav_header_main的XML文件 现在我想把它做成初始一个登陆按钮,在另一个页面登陆后根据服务器数据库返回的信息把这个layout的nav_header_main的XML文件更改成用户的简介(用户名头像等),数据库大致解决了,安卓方面欠缺,求教导,谢谢
android dialog弹出时隐藏导航栏 navigation bar
隐藏安卓底部导航栏之后 弹出dialog或者popupwindow后导航栏会再次显示出来,可以设置在dialog的onStart中再次隐藏导航栏,但是会出现一个导航栏显示出来又马上隐藏掉的一个效果,请问有什么方法能避免这个事情的发生,让弹出dialog时导航栏没有出现?还有就是同样的方法在popupwindow的show和dismiss中无效..
Android中,下面一段代码怎么改才能正常运行打电话功能?
MainActivity.java ``` package com.example.a; import java.util.ArrayList; import java.util.HashMap; import android.app.Activity; import android.app.ActionBar; import android.app.Fragment; import android.app.FragmentTransaction; import android.app.ActionBar.Tab; import android.content.Intent; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.content.res.Resources; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Bundle; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.Button; import android.widget.ListView; import android.widget.SimpleAdapter; import android.os.Build; public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.actionbar_tab); final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayShowTitleEnabled(false); //隐藏icon actionBar.setDisplayShowHomeEnabled(false); //隐藏标题 alistAction alist = new alistAction(); Tab tab1 = actionBar.newTab(); tab1.setText("列表"); tab1.setIcon(R.drawable.ic_launcher); tab1.setTabListener(new ListenerA(alist)); actionBar.addTab(tab1); Button btnCall=(Button)findViewById(R.id.tbnCall); btnCall=(Button) findViewById(R.id.tbnCall); btnCall.setOnClickListener(new OnClickListener() { public void onClick(View v) { startActivity(new Intent(Intent.ACTION_CALL,Uri.parse("tel://10086"))); } }); } private class ListenerA implements ActionBar.TabListener { private alistAction alist; public ListenerA(alistAction fragment) { alist = fragment; } public void onTabSelected(Tab tab, FragmentTransaction ft) { ft.add(R.id.fragment_content, alist, null); } public void onTabUnselected(Tab tab, FragmentTransaction ft) { ft.remove(alist); } public void onTabReselected(Tab tab, FragmentTransaction ft) { } } } ``` actionbar_tab.xml ``` <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/fragment_content" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > </LinearLayout> ``` alist.xml ``` <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <ImageView android:id="@+id/imgHead" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="false" android:layout_centerInParent="false" android:layout_marginLeft="25dp" android:layout_marginTop="10dp" android:src="@drawable/ic_launcher" /> <TextView android:id="@+id/txtName" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignTop="@+id/imgHead" android:layout_centerHorizontal="false" android:layout_toRightOf="@+id/imgHead" android:text="Name" /> <TextView android:id="@+id/txtPhome" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@+id/imgHead" android:layout_centerHorizontal="false" android:layout_toRightOf="@+id/imgHead" android:text="Phone" /> <Button android:id="@+id/tbnCall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignTop="@+id/txtName" android:layout_marginLeft="75dp" android:layout_toRightOf="@+id/txtName" android:text="拨号" /> </RelativeLayout> ``` alistAction ``` package com.example.a; import java.util.ArrayList; import java.util.HashMap; import java.util.zip.Inflater; import android.app.Activity; import android.app.Fragment; import android.content.Context; import android.os.Bundle; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ListView; import android.widget.SimpleAdapter; public class alistAction extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View image = inflater.inflate(R.layout.alist, container, false); return image; } } ```
如何把echarts的js示例应用到vue的百度地图中
https://www.echartsjs.com/examples/zh/editor.html?c=map-bin 这个例子用的百度地图,但怎么在vue中整合这种网格效果呢。 ``` <template> <baidu-map class="map" :center="{lng: 116.404, lat: 39.915}" :zoom="15" :scroll-wheel-zoom="true"> <bm-navigation anchor="BMAP_ANCHOR_TOP_RIGHT"></bm-navigation> <bm-scale anchor="BMAP_ANCHOR_TOP_RIGHT"></bm-scale> <bm-geolocation anchor="BMAP_ANCHOR_BOTTOM_RIGHT" :showAddressBar="true" :autoLocation="true"></bm-geolocation> <bm-city-list anchor="BMAP_ANCHOR_TOP_LEFT"></bm-city-list> <bm-panorama></bm-panorama> </baidu-map> </template> <script> export default { data () { return { center: {lng: 0, lat: 0}, zoom: 3 } }, methods: { handler ({BMap, map}) { console.log(BMap, map) this.center.lng = 116.404 this.center.lat = 39.915 this.zoom = 15 }, } } </script> <style> .map { width: 100%; height: 800px; } </style> ``` 这是我vue现在的地图页面,想把网格效果融入进去,怎么操作
Mining Station on the Sea 怎么来写呢
Problem Description The ocean is a treasure house of resources and the development of human society comes to depend more and more on it. In order to develop and utilize marine resources, it is necessary to build mining stations on the sea. However, due to seabed mineral resources, the radio signal in the sea is often so weak that not all the mining stations can carry out direct communication. However communication is indispensable, every two mining stations must be able to communicate with each other (either directly or through other one or more mining stations). To meet the need of transporting the exploited resources up to the land to get put into use, there build n ports correspondently along the coast and every port can communicate with one or more mining stations directly. Due to the fact that some mining stations can not communicate with each other directly, for the safety of the navigation for ships, ships are only allowed to sail between mining stations which can communicate with each other directly. The mining is arduous and people do this job need proper rest (that is, to allow the ship to return to the port). But what a coincidence! This time, n vessels for mining take their turns to take a rest at the same time. They are scattered in different stations and now they have to go back to the port, in addition, a port can only accommodate one vessel. Now all the vessels will start to return, how to choose their navigation routes to make the total sum of their sailing routes minimal. Notice that once the ship entered the port, it will not come out! Input There are several test cases. Every test case begins with four integers in one line, n (1 = <n <= 100), m (n <= m <= 200), k and p. n indicates n vessels and n ports, m indicates m mining stations, k indicates k edges, each edge corresponding to the link between a mining station and another one, p indicates p edges, each edge indicating the link between a port and a mining station. The following line is n integers, each one indicating one station that one vessel belongs to. Then there follows k lines, each line including 3 integers a, b and c, indicating the fact that there exists direct communication between mining stations a and b and the distance between them is c. Finally, there follows another p lines, each line including 3 integers d, e and f, indicating the fact that there exists direct communication between port d and mining station e and the distance between them is f. In addition, mining stations are represented by numbers from 1 to m, and ports 1 to n. Input is terminated by end of file. Output Each test case outputs the minimal total sum of their sailing routes. Sample Input 3 5 5 6 1 2 4 1 3 3 1 4 4 1 5 5 2 5 3 2 4 3 1 1 5 1 5 3 2 5 3 2 4 6 3 1 4 3 2 2 Sample Output 13
/usr/bin/ld: cannot find -lOPTIONS 无法找到OPTIONS库。
我在UBUNTU 18.04 下用CUDA 10.2 和 C++11标准编译一个较大的工程。 Makefile 是用CMAKE文件生成的。当我在terminal完成编译时显示了如下错误: ``` /usr/bin/ld: cannot find -lOPTIONS collect2: error: ld returned 1 exit status CMakeFiles/cuda_othermain.dir/build.make:132: recipe for target 'bin/cuda_othermain' failed make[2]: *** [bin/cuda_othermain] Error 1 CMakeFiles/Makefile2:79: recipe for target 'CMakeFiles/cuda_othermain.dir/all' failed make[1]: *** [CMakeFiles/cuda_othermain.dir/all] Error 2 Makefile:83: recipe for target 'all' failed make: *** [all] Error 2 ``` 提示是找不到一个叫OPTIONS的库。我的camke和源码里都没有链接这个库,而且我在网上搜索也根本没有一个库叫做OPTIONS。我很疑惑,编译工程时没有显示任何其他错误,顶多就是有几个warning,我查了一下都是没有太大关系的。所以现在没有什么思路去解决这个问题。 所以想请教一下各位有没有什么解决思路。 CMAKE文件如下: ``` cmake_minimum_required (VERSION 3.8 FATAL_ERROR) #project (cusam_cuda) project(cusam_cuda LANGUAGES C CXX CUDA) find_package(CUDA 10.2 REQUIRED) set(CUDA_NVCC_FLAGS -std=c++11 -L/usr/local/cuda-10.2/lib64 -lcudart -lcuda) set(CMAKE_CXX_STANDARD 11) if (CUDA_VERBOSE_PTXAS) set(VERBOSE_PTXAS --ptxas-options=-v) endif (CUDA_VERBOSE_PTXAS) #set(CMAKE_BUILD_TYPE "Release") set(CMAKE_BUILD_TYPE "Debug") SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CUDA_NVCC_FLAGS} -O0 -Wall -g -ggdb") SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CUDA_NVCC_FLAGS} -O3 -Wall") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(GENCODE_SM30 -gencode=arch=compute_30,code=sm_30 -gencode=arch=compute_30,code=compute_30) set(GENCODE_SM35 -gencode=arch=compute_35,code=sm_35 -gencode=arch=compute_35,code=compute_35) set(GENCODE_SM37 -gencode=arch=compute_37,code=sm_37 -gencode=arch=compute_37,code=compute_37) set(GENCODE_SM50 -gencode=arch=compute_50,code=sm_50 -gencode=arch=compute_50,code=compute_50) set(GENCODE_SM60 -gencode=arch=compute_60,code=sm_60 -gencode=arch=compute_60,code=compute_60) set(GENCODE_SM61 -gencode=arch=compute_61,code=sm_61 -gencode=arch=compute_61,code=compute_61) set(GENCODE_SM70 -gencode=arch=compute_70,code=sm_70 -gencode=arch=compute_70,code=compute_70) set(GENCODE_SM71 -gencode=arch=compute_71,code=sm_71 -gencode=arch=compute_71,code=compute_71) set(GENCODE_SM75 -gencode=arch=compute_75,code=sm_75 -gencode=arch=compute_75,code=compute_75) option(CUDAMATRIX_GENCODE_SM30 "GENCODE_SM30" OFF) option(CUDAMATRIX_GENCODE_SM35 "GENCODE_SM35" ON) option(CUDAMATRIX_GENCODE_SM37 "GENCODE_SM37" OFF) option(CUDAMATRIX_GENCODE_SM50 "GENCODE_SM50" OFF) option(CUDAMATRIX_GENCODE_SM60 "GENCODE_SM60" OFF) option(CUDAMATRIX_GENCODE_SM61 "GENCODE_SM61" OFF) option(CUDAMATRIX_GENCODE_SM70 "GENCODE_SM70" OFF) option(CUDAMATRIX_GENCODE_SM71 "GENCODE_SM71" OFF) option(CUDAMATRIX_GENCODE_SM75 "GENCODE_SM75" OFF) if (CUDAMATRIX_GENCODE_SM37) set(GENCODE ${GENCODE} ${GENCODE_SM37}) endif(CUDAMATRIX_GENCODE_SM37) if (CUDAMATRIX_GENCODE_SM50) set(GENCODE ${GENCODE} ${GENCODE_SM50}) endif(CUDAMATRIX_GENCODE_SM50) if (CUDAMATRIX_GENCODE_SM60) set(GENCODE ${GENCODE} ${GENCODE_SM60}) endif(CUDAMATRIX_GENCODE_SM60) if (CUDAMATRIX_GENCODE_SM61) set(GENCODE ${GENCODE} ${GENCODE_SM61}) endif(CUDAMATRIX_GENCODE_SM61) if (CUDAMATRIX_GENCODE_SM70) set(GENCODE ${GENCODE} ${GENCODE_SM70}) endif(CUDAMATRIX_GENCODE_SM70) if(CUDAMATRIX_GENCODE_SM71) set(GENCODE ${GENCODE} ${GENCODE_SM71}) endif(CUDAMATRIX_GENCODE_SM71) if(CUDAMATRIX_GENCODE_SM75) set(GENCODE ${GENCODE} ${GENCODE_SM75}) endif(CUDAMATRIX_GENCODE_SM75) include_directories(/usr/local/cuda/include) include_directories(utils) #include_directories(3rdparty/googletest/googletest) #include_directories(3rdparty/googletest/googletest/include) #add_subdirectory(3rdparty/googletest/googletest googletest.out) add_subdirectory(geometry) add_subdirectory(navigation) add_subdirectory(3rdparty) add_subdirectory(nonlinear) add_subdirectory(inference) add_subdirectory(mat) add_subdirectory(miniblas) add_subdirectory(miniblas/cblas) add_subdirectory(miniblas/blas) add_subdirectory(miniblas/permutation) add_subdirectory(miniblas/sys) add_subdirectory(miniblas/linalg) add_subdirectory(linear) #add_subdirectory(test) #cuda_add_executable(imukittiexamplegps_gaussiannewton imukittiexamplegps_gaussiannewton.cpp # OPTIONS ${GENCODE} ${CUDA_VERBOSE_PTXAS}) #target_link_libraries(imukittiexamplegps_gaussiannewton geometry miniblas blas cblas linalg permutation sys navigation 3rdparty linear nonlinear inference mat) #cuda_add_executable(othermain othermain.cpp # OPTIONS ${GENCODE} ${CUDA_VERBOSE_PTXAS}) #target_link_libraries(othermain geometry miniblas blas cblas linalg permutation sys navigation 3rdparty linear nonlinear inference mat) target_compile_features(nonlinear PUBLIC cxx_std_11) cuda_add_executable(cuda_othermain cuda_othermain.cu OPTIONS ${GENCODE} ${CUDA_VERBOSE_PTXAS}) target_compile_features(cuda_othermain PUBLIC cxx_std_11) set_target_properties(cuda_othermain PROPERTIES CUDA_SEPARABLE_COMPILATION ON) target_link_libraries(cuda_othermain geometry miniblas blas cblas linalg permutation sys navigation 3rdparty linear nonlinear inference mat) ``` 源代码就没发帖了,因为工程还算比较大。有劳各位了。
Navy maneuvers 代码具体怎么写
Problem Description In times of peace, various countries have held regular maneuvers to maintain military’s vigilance. There is a navy fleet in a certain country which also starts a new round imaginary naval battle. At the maneuver stage, the admiral intends to assess the combat effectiveness of two warships, “Victory” and “Glory”, so he lets two warships carry out countering exercises. Both of the warship commanders are young and promising, who graduated from naval academy as outstanding students. Not only have they had rich navigation direction experiences, but also have profound scientific knowledge, especially in mathematics. The admiral appoints one marine area dotted with many islets. Suppose all these islets are occupied by the enemy, and there are positive integers of enemy firebases. The hypothetical exercise situations given by the admiral and the rule of the competition are as follows: (1) All the occupied islets are connected. There are some routes among these islets, but the route from one islet to another islet is unidirectional. In other words, if we take an islet as a node and an islet route as an edge, then we will get a directed non-cyclic connected graph. (2) There is a unique 1st islet in the graph. If we start from this islet, we can reach any other islet. (maybe the 1st islet is not the islet which is numbered 1) (3) At the beginning of the maneuver, two warships simultaneously sail to the 1st islets and eliminate all enemy firebases together. (4) The two warships, “Victory” and “Glory” take turns to navigate and exchange as soon as they arrive at an islet, then they move forward together. But each time they can only go along the unidirectional route, sail to the islet directly connected to the current, and eliminates all the enemy firebases on the islet. By the way, when start from 1st islet, “Victory” first navigates. (5) Because each route is unidirectional, and graph is non-cycle, therefore the maneuver terminates when the two warships fail to go on navigating. (6)When the maneuver ends, sum the numbers of eliminated enemy firebases on the routing path. If the number is greater than or equal to certain number f assigned by the admiral, then “Victory” wins. Otherwise, “Glory” wins. The warship commanders are both mathematicians. After being assigned to such task, they see it is a Graph Theory problem. On the first simple directed non-cyclic connected graph, each node has a certain positive integer,it indicates the enemy firebases. The assignment is that two captains take turn to move forward along the directed edge until they are unable to do so. Then sum the total positive integers of the nodes on the routing path. Compare the number with the certain number f, and decides the final winning or losses. Therefore, when it is the time for their own navigation, they are supposed to choose the route to win the final success. Input There are several test cases, in each case there are three positive integers n, m and f in first line. n indicates there are n (1< n <10000 ) nodes in the graph. The node serial number is arranged from 1 to n. m indicates that there are m edges in the graph. The following line has n positive integers, which indicate in sequence the positive integers in the nodes. Finally, there are m lines, and each line has two positive integers a, b (1< = a, b< =n), indicating there is a directed edge from the a node to the b node. Input is terminated by the end of file. Output To each group of the test case, if “Victory” wins, then output “Victory”. Otherwise, output “Glory”. The output each case takes up one line. Sample Input 4 4 7 2 2 2 2 4 2 2 1 4 3 3 1 4 5 6 1 2 3 4 1 2 1 3 1 4 2 3 4 3 Sample Output Glory Victory
Web Navigation 导航问题
Description Standard web browsers contain features to move backward and forward among the pages recently visited. One way to implement these features is to use two stacks to keep track of the pages that can be reached by moving backward and forward. In this problem, you are asked to implement this. The following commands need to be supported: BACK: Push the current page on the top of the forward stack. Pop the page from the top of the backward stack, making it the new current page. If the backward stack is empty, the command is ignored. FORWARD: Push the current page on the top of the backward stack. Pop the page from the top of the forward stack, making it the new current page. If the forward stack is empty, the command is ignored. VISIT : Push the current page on the top of the backward stack, and make the URL specified the new current page. The forward stack is emptied. QUIT: Quit the browser. Assume that the browser initially loads the web page at the URL http://www.acm.org/ Input Input is a sequence of commands. The command keywords BACK, FORWARD, VISIT, and QUIT are all in uppercase. URLs have no whitespace and have at most 70 characters. You may assume that no problem instance requires more than 100 elements in each stack at any time. The end of input is indicated by the QUIT command. Output For each command other than QUIT, print the URL of the current page after the command is executed if the command is not ignored. Otherwise, print "Ignored". The output for each command should be printed on its own line. No output is produced for the QUIT command. Sample Input VISIT http://acm.ashland.edu/ VISIT http://acm.baylor.edu/acmicpc/ BACK BACK BACK FORWARD VISIT http://www.ibm.com/ BACK BACK FORWARD FORWARD FORWARD QUIT
爬虫福利二 之 妹子图网MM批量下载
爬虫福利一:27报网MM批量下载 点击 看了本文,相信大家对爬虫一定会产生强烈的兴趣,激励自己去学习爬虫,在这里提前祝:大家学有所成! 目标网站:妹子图网 环境:Python3.x 相关第三方模块:requests、beautifulsoup4 Re:各位在测试时只需要将代码里的变量path 指定为你当前系统要保存的路径,使用 python xxx.py 或IDE运行即可。 ...
Java学习的正确打开方式
在博主认为,对于入门级学习java的最佳学习方法莫过于视频+博客+书籍+总结,前三者博主将淋漓尽致地挥毫于这篇博客文章中,至于总结在于个人,实际上越到后面你会发现学习的最好方式就是阅读参考官方文档其次就是国内的书籍,博客次之,这又是一个层次了,这里暂时不提后面再谈。博主将为各位入门java保驾护航,各位只管冲鸭!!!上天是公平的,只要不辜负时间,时间自然不会辜负你。 何谓学习?博主所理解的学习,它是一个过程,是一个不断累积、不断沉淀、不断总结、善于传达自己的个人见解以及乐于分享的过程。
大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了
大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...
linux系列之常用运维命令整理笔录
本博客记录工作中需要的linux运维命令,大学时候开始接触linux,会一些基本操作,可是都没有整理起来,加上是做开发,不做运维,有些命令忘记了,所以现在整理成博客,当然vi,文件操作等就不介绍了,慢慢积累一些其它拓展的命令,博客不定时更新 free -m 其中:m表示兆,也可以用g,注意都要小写 Men:表示物理内存统计 total:表示物理内存总数(total=used+free) use...
比特币原理详解
一、什么是比特币 比特币是一种电子货币,是一种基于密码学的货币,在2008年11月1日由中本聪发表比特币白皮书,文中提出了一种去中心化的电子记账系统,我们平时的电子现金是银行来记账,因为银行的背后是国家信用。去中心化电子记账系统是参与者共同记账。比特币可以防止主权危机、信用风险。其好处不多做赘述,这一层面介绍的文章很多,本文主要从更深层的技术原理角度进行介绍。 二、问题引入 假设现有4个人...
程序员接私活怎样防止做完了不给钱?
首先跟大家说明一点,我们做 IT 类的外包开发,是非标品开发,所以很有可能在开发过程中会有这样那样的需求修改,而这种需求修改很容易造成扯皮,进而影响到费用支付,甚至出现做完了项目收不到钱的情况。 那么,怎么保证自己的薪酬安全呢? 我们在开工前,一定要做好一些证据方面的准备(也就是“讨薪”的理论依据),这其中最重要的就是需求文档和验收标准。一定要让需求方提供这两个文档资料作为开发的基础。之后开发...
网页实现一个简单的音乐播放器(大佬别看。(⊙﹏⊙))
今天闲着无事,就想写点东西。然后听了下歌,就打算写个播放器。 于是乎用h5 audio的加上js简单的播放器完工了。 演示地点演示 html代码如下` music 这个年纪 七月的风 音乐 ` 然后就是css`*{ margin: 0; padding: 0; text-decoration: none; list-...
Python十大装B语法
Python 是一种代表简单思想的语言,其语法相对简单,很容易上手。不过,如果就此小视 Python 语法的精妙和深邃,那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点,并附上详细的实例代码。如能在实战中融会贯通、灵活使用,必将使代码更为精炼、高效,同时也会极大提升代码B格,使之看上去更老练,读起来更优雅。
数据库优化 - SQL优化
以实际SQL入手,带你一步一步走上SQL优化之路!
2019年11月中国大陆编程语言排行榜
2019年11月2日,我统计了某招聘网站,获得有效程序员招聘数据9万条。针对招聘信息,提取编程语言关键字,并统计如下: 编程语言比例 rank pl_ percentage 1 java 33.62% 2 cpp 16.42% 3 c_sharp 12.82% 4 javascript 12.31% 5 python 7.93% 6 go 7.25% 7 p...
通俗易懂地给女朋友讲:线程池的内部原理
餐盘在灯光的照耀下格外晶莹洁白,女朋友拿起红酒杯轻轻地抿了一小口,对我说:“经常听你说线程池,到底线程池到底是个什么原理?”
经典算法(5)杨辉三角
杨辉三角 是经典算法,这篇博客对它的算法思想进行了讲解,并有完整的代码实现。
腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹?
昨天,有网友私信我,说去阿里面试,彻底的被打击到了。问了为什么网上大量使用ThreadLocal的源码都会加上private static?他被难住了,因为他从来都没有考虑过这个问题。无独有偶,今天笔者又发现有网友吐槽了一道腾讯的面试题,我们一起来看看。 腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹? 在互联网职场论坛,一名程序员发帖求助到。二面腾讯,其中一个算法题:64匹...
面试官:你连RESTful都不知道我怎么敢要你?
干货,2019 RESTful最贱实践
JDK12 Collectors.teeing 你真的需要了解一下
前言 在 Java 12 里面有个非常好用但在官方 JEP 没有公布的功能,因为它只是 Collector 中的一个小改动,它的作用是 merge 两个 collector 的结果,这句话显得很抽象,老规矩,我们先来看个图(这真是一个不和谐的图????): 管道改造经常会用这个小东西,通常我们叫它「三通」,它的主要作用就是将 downstream1 和 downstre...
为啥国人偏爱Mybatis,而老外喜欢Hibernate/JPA呢?
关于SQL和ORM的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行了一番讨论,感触还是有一些,于是就有了今天这篇文。 声明:本文不会下关于Mybatis和JPA两个持久层框架哪个更好这样的结论。只是摆事实,讲道理,所以,请各位看官勿喷。 一、事件起因 关于Mybatis和JPA孰优孰劣的问题,争论已经很多年了。一直也没有结论,毕竟每个人的喜好和习惯是大不相同的。我也看...
SQL-小白最佳入门sql查询一
不要偷偷的查询我的个人资料,即使你再喜欢我,也不要这样,真的不好;
项目中的if else太多了,该怎么重构?
介绍 最近跟着公司的大佬开发了一款IM系统,类似QQ和微信哈,就是聊天软件。我们有一部分业务逻辑是这样的 if (msgType = "文本") { // dosomething } else if(msgType = "图片") { // doshomething } else if(msgType = "视频") { // doshomething } else { // doshom...
【图解经典算法题】如何用一行代码解决约瑟夫环问题
约瑟夫环问题算是很经典的题了,估计大家都听说过,然后我就在一次笔试中遇到了,下面我就用 3 种方法来详细讲解一下这道题,最后一种方法学了之后保证让你可以让你装逼。 问题描述:编号为 1-N 的 N 个士兵围坐在一起形成一个圆圈,从编号为 1 的士兵开始依次报数(1,2,3…这样依次报),数到 m 的 士兵会被杀死出列,之后的士兵再从 1 开始报数。直到最后剩下一士兵,求这个士兵的编号。 1、方...
致 Python 初学者
欢迎来到“Python进阶”专栏!来到这里的每一位同学,应该大致上学习了很多 Python 的基础知识,正在努力成长的过程中。在此期间,一定遇到了很多的困惑,对未来的学习方向感到迷茫。我非常理解你们所面临的处境。我从2007年开始接触 python 这门编程语言,从2009年开始单一使用 python 应对所有的开发工作,直至今天。回顾自己的学习过程,也曾经遇到过无数的困难,也曾经迷茫过、困惑过。开办这个专栏,正是为了帮助像我当年一样困惑的 Python 初学者走出困境、快速成长。希望我的经验能真正帮到你
“狗屁不通文章生成器”登顶GitHub热榜,分分钟写出万字形式主义大作
一、垃圾文字生成器介绍 最近在浏览GitHub的时候,发现了这样一个骨骼清奇的雷人项目,而且热度还特别高。 项目中文名:狗屁不通文章生成器 项目英文名:BullshitGenerator 根据作者的介绍,他是偶尔需要一些中文文字用于GUI开发时测试文本渲染,因此开发了这个废话生成器。但由于生成的废话实在是太过富于哲理,所以最近已经被小伙伴们给玩坏了。 他的文风可能是这样的: 你发现,...
程序员:我终于知道post和get的区别
是一个老生常谈的话题,然而随着不断的学习,对于以前的认识有很多误区,所以还是需要不断地总结的,学而时习之,不亦说乎
GitHub标星近1万:只需5秒音源,这个网络就能实时“克隆”你的声音
作者 | Google团队 译者 | 凯隐 编辑 | Jane 出品 | AI科技大本营(ID:rgznai100) 本文中,Google 团队提出了一种文本语音合成(text to speech)神经系统,能通过少量样本学习到多个不同说话者(speaker)的语音特征,并合成他们的讲话音频。此外,对于训练时网络没有接触过的说话者,也能在不重新训练的情况下,仅通过未知...
《程序人生》系列-这个程序员只用了20行代码就拿了冠军
你知道的越多,你不知道的越多 点赞再看,养成习惯GitHub上已经开源https://github.com/JavaFamily,有一线大厂面试点脑图,欢迎Star和完善 前言 这一期不算《吊打面试官》系列的,所有没前言我直接开始。 絮叨 本来应该是没有这期的,看过我上期的小伙伴应该是知道的嘛,双十一比较忙嘛,要值班又要去帮忙拍摄年会的视频素材,还得搞个程序员一天的Vlog,还要写BU...
加快推动区块链技术和产业创新发展,2019可信区块链峰会在京召开
11月8日,由中国信息通信研究院、中国通信标准化协会、中国互联网协会、可信区块链推进计划联合主办,科技行者协办的2019可信区块链峰会将在北京悠唐皇冠假日酒店开幕。   区块链技术被认为是继蒸汽机、电力、互联网之后,下一代颠覆性的核心技术。如果说蒸汽机释放了人类的生产力,电力解决了人类基本的生活需求,互联网彻底改变了信息传递的方式,区块链作为构造信任的技术有重要的价值。   1...
程序员把地府后台管理系统做出来了,还有3.0版本!12月7号最新消息:已在开发中有github地址
第一幕:缘起 听说阎王爷要做个生死簿后台管理系统,我们派去了一个程序员…… 996程序员做的梦: 第一场:团队招募 为了应对地府管理危机,阎王打算找“人”开发一套地府后台管理系统,于是就在地府总经办群中发了项目需求。 话说还是中国电信的信号好,地府都是满格,哈哈!!! 经常会有外行朋友问:看某网站做的不错,功能也简单,你帮忙做一下? 而这次,面对这样的需求,这个程序员...
网易云6亿用户音乐推荐算法
网易云音乐是音乐爱好者的集聚地,云音乐推荐系统致力于通过 AI 算法的落地,实现用户千人千面的个性化推荐,为用户带来不一样的听歌体验。 本次分享重点介绍 AI 算法在音乐推荐中的应用实践,以及在算法落地过程中遇到的挑战和解决方案。 将从如下两个部分展开: AI算法在音乐推荐中的应用 音乐场景下的 AI 思考 从 2013 年 4 月正式上线至今,网易云音乐平台持续提供着:乐屏社区、UGC...
【技巧总结】位运算装逼指南
位算法的效率有多快我就不说,不信你可以去用 10 亿个数据模拟一下,今天给大家讲一讲位运算的一些经典例子。不过,最重要的不是看懂了这些例子就好,而是要在以后多去运用位运算这些技巧,当然,采用位运算,也是可以装逼的,不信,你往下看。我会从最简单的讲起,一道比一道难度递增,不过居然是讲技巧,那么也不会太难,相信你分分钟看懂。 判断奇偶数 判断一个数是基于还是偶数,相信很多人都做过,一般的做法的代码如下...
【管理系统课程设计】美少女手把手教你后台管理
【文章后台管理系统】URL设计与建模分析+项目源码+运行界面 栏目管理、文章列表、用户管理、角色管理、权限管理模块(文章最后附有源码) 1. 这是一个什么系统? 1.1 学习后台管理系统的原因 随着时代的变迁,现如今各大云服务平台横空出世,市面上有许多如学生信息系统、图书阅读系统、停车场管理系统等的管理系统,而本人家里就有人在用烟草销售系统,直接在网上完成挑选、购买与提交收货点,方便又快捷。 试想,若没有烟草销售系统,本人家人想要购买烟草,还要独自前往药...
4G EPS 第四代移动通信系统
目录 文章目录目录4G 与 LTE/EPCLTE/EPC 的架构E-UTRANE-UTRAN 协议栈eNodeBEPCMMES-GWP-GWHSSLTE/EPC 协议栈概览 4G 与 LTE/EPC 4G,即第四代移动通信系统,提供了 3G 不能满足的无线网络宽带化,主要提供数据(上网)业务。而 LTE(Long Term Evolution,长期演进技术)是电信领域用于手机及数据终端的高速无线通...
相关热词 c#处理浮点数 c# 生成字母数字随机数 c# 动态曲线 控件 c# oracle 开发 c#选择字体大小的控件 c# usb 批量传输 c#10进制转8进制 c#转base64 c# 科学计算 c#下拉列表获取串口
立即提问