<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > Android常用控件之下拉刷新Wifi列表

          Android常用控件之下拉刷新Wifi列表

          作者: 時間:2016-09-12 來源:網(wǎng)絡(luò) 收藏

          import android.widget.BaseAdapter;

          import android.widget.LinearLayout;

          import android.widget.TextView;

          import com.example.dropdownrefresh.ui.DropdownListView;

          import com.example.dropdownrefresh.ui.DropdownListView.OnRefreshListener;

          import com.example.dropdownrefresh.utils.WifiAdmin;

          /**

          * 使用下拉刷新搜索wifi

          * @author Administrator

          *

          */

          public class MainActivity extends Activity {

          WifiAdmin wifiAdmin = null;

          private ArrayList

          private BaseAdapter adapter;

          @Override

          protected void onCreate(Bundle savedInstanceState) {

          super.onCreate(savedInstanceState);

          setContentView(R.layout.main);

          wifiAdmin = new WifiAdmin(this);

          list = new ArrayList

          RefreshList();

          final DropdownListView listView = (DropdownListView) findViewById(R.id.listView);

          adapter = new BaseAdapter() {

          public View getView(int position, View convertView, ViewGroup parent) {

          LinearLayout layout = new LinearLayout(getApplicationContext());

          layout.setOrientation(LinearLayout.VERTICAL); //垂直布局

          HashMap

          TextView txtName = new TextView(getApplicationContext());

          TextView txtSignal = new TextView(getApplicationContext());

          txtName.setText(map.get(wifi_name));

          txtSignal.setText(map.get(wifi_signal));

          layout.addView(txtName);

          layout.addView(txtSignal);

          return layout;

          }

          public long getItemId(int position) {

          return 0;

          }

          public Object getItem(int position) {

          return null;

          }

          public int getCount() {

          return list.size();

          }

          };

          listView.setAdapter(adapter);

          listView.setonRefreshListener(new OnRefreshListener() {

          public void onRefresh() {

          new AsyncTask

          protected Void doInBackground(Void... params) {

          try {

          Thread.sleep(1000);

          } catch (Exception e) {

          e.printStackTrace();

          }

          list.clear();

          RefreshList();

          return null;

          }

          @Override

          protected void onPostExecute(Void result) {

          adapter.notifyDataSetChanged();

          listView.onRefreshComplete();

          }

          }.execute(null, null, null);

          }

          });

          }

          private void RefreshList(){

          wifiAdmin.startScan(); // 掃描wifi熱點(diǎn),前提是wifi已經(jīng)打開

          List wifiList = wifiAdmin.getWifiList();

          for (int index = 0; index wifiList.size(); index++) {

          HashMap

          map.put(wifi_name, (wifiList.get(index)).SSID);

          map.put(wifi_signal, signal:

          + (-(wifiList.get(index)).level) + %);

          list.add(map);

          }

          }

          }



          關(guān)鍵詞:

          評論


          相關(guān)推薦

          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();