91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

android 開源項目(城市定位)

發布時間:2020-07-19 16:52:07 來源:網絡 閱讀:1418 作者:風清揚lfg 欄目:移動開發

import java.util.ArrayList;


import org.json.JSONArray;

import org.json.JSONException;

import org.json.JSONObject;

import org.lfg.Utils.MyVolley;

import org.lfg.Utils.StringRequestUTF;

import org.lfg.cityselect_activity.CityHomeActivity;

import org.lfg.widgets.ListViewForScrollView;


import BaseAdapter.Contains;

import android.annotation.SuppressLint;

import android.content.Intent;

import android.os.Bundle;

import android.support.v4.app.Fragment;

import android.view.LayoutInflater;

import android.view.View;

import android.view.View.OnClickListener;

import android.view.ViewGroup;

import android.widget.BaseAdapter;

import android.widget.Button;

import android.widget.ImageButton;

import android.widget.ImageView;

import android.widget.ScrollView;

import android.widget.TextView;

import android.widget.Toast;


import com.android.volley.Request.Method;

import com.android.volley.RequestQueue;

import com.android.volley.Response.ErrorListener;

import com.android.volley.Response.Listener;

import com.android.volley.VolleyError;

import com.android.volley.toolbox.StringRequest;

import com.example.nuomi.AllActivity;

import com.example.nuomi.R;

import com.handmark.pulltorefresh.library.MyScrollView;

import com.handmark.pulltorefresh.library.MyScrollView.OnScrollListener;

import com.handmark.pulltorefresh.library.PullToRefreshBase;

import com.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener;

import com.handmark.pulltorefresh.library.PullToRefreshScrollView;

import com.nostra13.universalp_w_picpathloader.core.DisplayImageOptions;

import com.nostra13.universalp_w_picpathloader.core.ImageLoader;


public class todayFragment extends Fragment  

{

private ListViewForScrollView mlistmnue;

private PullToRefreshScrollView mScrollview;

protected ImageLoader p_w_picpathLoader = ImageLoader.getInstance();

private ArrayList<MenuList>  context = new ArrayList<todayFragment.MenuList>();

private String strUrl = Contains.strUrl;

private DisplayImageOptions options;

private mlistmnueAdapter mAdapter;

private TextView mTvall;

private ImageButton mBtnBackTop;

private Button mLocationcity;

    

@Override

  public View onCreateView(LayoutInflater inflater, ViewGroup container,

Bundle savedInstanceState) 

  {

View layout = inflater.inflate(R.layout.home, null);

        InitUI(layout);

Options();

InitScroll(layout);

HttpConn();

return layout;

  }

/*

 *  卻接受CityHomeActivity的消息

 */

@Override

public void onActivityResult(int requestCode, int resultCode, Intent data) {

if(data != null)

{

if(resultCode == 1)

{

String cityName = data.getStringExtra("city");

int end = cityName.indexOf("市");

mLocationcity.setText(cityName.substring(0, end));

}

}else

{

          Toast.makeText(getActivity(), "親!定位失敗哦~~~", Toast.LENGTH_SHORT).show();

}

super.onActivityResult(requestCode, resultCode, data);

}

private void InitUI(View layout) {

mBtnBackTop = (ImageButton) layout.findViewById(R.id.img_backtop);

         mBtnBackTop.setOnClickListener(new OnClickListener() {


@Override

public void onClick(View v) {

ScrollView scrollView = (ScrollView) mScrollview.findViewById(R.id.scrollview);

scrollView.smoothScrollTo(0, 0);

}

});

         

//       跳轉全部團購頁面

         TextView find_more = (TextView) layout.findViewById(R.id.find_more);

         find_more.setOnClickListener(new OnClickListener() {

@Override

public void onClick(View v) {

                Intent intent = new Intent(getActivity(),AllActivity.class);

startActivity(intent );                      

}

});

         

//       定位城市事件

         mLocationcity = (Button) layout.findViewById(R.id.btn_locationcity);

         mLocationcity.setOnClickListener(new OnClickListener() {

@Override

public void onClick(View v) {

Intent intent = new Intent(getActivity(),CityHomeActivity.class);

startActivityForResult(intent, 0);

}

});

         

}

 


@SuppressLint("NewApi")

private void HttpConn() {

Listener<String> listener = new Listener<String>() 

{

@Override

public void onResponse(String response) 

{

try {

JSONObject  jsonObj = new JSONObject(response);

JSONArray jsonarr = jsonObj.getJSONArray("deals");

    for (int i = 0; i < jsonarr.length(); i++) 

    {

    JSONObject jsonObject = jsonarr.getJSONObject(i);

String name = jsonObject.getString("name");

String thumbnail = jsonObject.getString("thumbnail");

String solds = jsonObject.getString("solds");

String price = jsonObject.getString("price");

String value = jsonObject.getString("value");

String title = jsonObject.getString("title");

MenuList menuList = new MenuList(name,thumbnail,solds,price,value,title);

context.add(menuList);

}

} catch (JSONException e) {

e.printStackTrace();

}

mAdapter.notifyDataSetChanged();

}

};

ErrorListener errorListener = new ErrorListener() 

{

@Override

public void onErrorResponse(VolleyError error) 

{

//   Toast.makeText(getActivity(), "網絡連接有問題"+error, Toast.LENGTH_SHORT).show();

}

};

volleyGet(strUrl, listener, errorListener);

}


// 下載文件(注意結合ListView 數據設置始終是去設置ListView)

private void volleyGet(String url, Listener<String> listener,

ErrorListener errorListener)

{

RequestQueue queue = MyVolley.getRequestQueue();

StringRequest request =

new StringRequestUTF(Method.GET,url,listener,errorListener);

queue.add(request);

}

//  圖片下載前、顯示

private void Options() 

{

options = new DisplayImageOptions.Builder()

.showImageOnLoading(R.drawable.about_logo)

.showImageForEmptyUri(R.drawable.about_logo)

.showImageOnFail(R.drawable.about_logo)

.cacheInMemory(true)

.cacheOnDisk(true)

.considerExifParams(true)

// .displayer(new RoundedBitmapDisplayer(8))

.build();

}

 

// 解決ScrollView滑動的問題

private void InitScroll(View layout) {

mlistmnue = (ListViewForScrollView) layout.findViewById(R.id.listViewForScrollView1);

mAdapter = new mlistmnueAdapter();

mlistmnue.setAdapter(mAdapter);

// 使用ScrollView滑動到最頂部

        mScrollview = (PullToRefreshScrollView) layout.findViewById(R.id.scrollView1);

        MyScrollView scrollView = (MyScrollView) mScrollview.findViewById(R.id.scrollview);

        

        scrollView.setOnScrollListener(new OnScrollListener() {

@Override

public void onScroll(int scrollY) {

if (scrollY == 0)

{

mBtnBackTop.setVisibility(View.INVISIBLE);

}

else

{

mBtnBackTop.setVisibility(View.VISIBLE);

}

}

});

        

        scrollView.smoothScrollTo(0, 0);

        

        mScrollview.setOnRefreshListener(new OnRefreshListener() {

@Override

public void onRefresh(PullToRefreshBase refreshView) {

new Thread()

{

@Override

public void run() {

try {

Thread.sleep(3000);

} catch (InterruptedException e) {

 

e.printStackTrace();

}

getActivity().runOnUiThread( new Runnable() {

public void run() {

mScrollview.onRefreshComplete();

}

});

}

}.start();

}

});

}   

private ImageView mbackTop;

//    設置適配器

class mlistmnueAdapter extends BaseAdapter

{

@Override

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

{

ListInfo listInfo = null;

View inflate = null;

if(convertView == null)

{

listInfo = new ListInfo();

inflate = getActivity().getLayoutInflater().inflate(R.layout.munulist, null);

listInfo.LTiltle = (TextView) inflate.findViewById(R.id.Title);

listInfo.LStore = (TextView) inflate.findViewById(R.id.Store);

listInfo.LDesContext = (TextView) inflate.findViewById(R.id.DesContext);

listInfo.LCurrprice = (TextView) inflate.findViewById(R.id.Currprice);

listInfo.LOldprice = (TextView) inflate.findViewById(R.id.Oldprice);

listInfo.LCount = (TextView) inflate.findViewById(R.id.Count);

listInfo.mImageView = (ImageView) inflate.findViewById(R.id.p_w_picpath_advertes);

 

// 解決如何去實現點擊跳到頂部

// mbackTop = (ImageView) inflate.findViewById(R.id.img_backtop);

 

inflate.setTag(listInfo);

}

else

{

inflate = convertView;

listInfo = (ListInfo) inflate.getTag();

}

// scrollView.smoothScrollTo(0, 0);

MenuList menuList = context.get(position);

listInfo.LTiltle.setText(menuList.name);

String img = menuList.thumbnail;

p_w_picpathLoader .displayImage(

img, 

listInfo.mImageView, 

options, 

null);

return inflate;

}

@Override

public int getCount() 

{

return context.size();

}


@Override

public Object getItem(int position) 

{

return null;

}


@Override

public long getItemId(int position) 

{

return 0;

}

}

 

class ListInfo 

{

TextView LTiltle ;

TextView LStore;

TextView LDesContext;

TextView LCurrprice;

TextView LOldprice;

TextView LCount;

ImageView mImageView;

   }

class MenuList 

{

private String name;

private String thumbnail;

private String solds;

private String price;

private String value;

private String address;


public MenuList(String name, String thumbnail, String solds,

String price, String value, String address) {

this.name = name;

this.thumbnail = thumbnail;

this.solds = solds;

this.price = price;

this.value = value;

this.address = address;

}


@Override

public String toString() {

return "MenuList [name=" + name + ", img=" + thumbnail + ", solds="

+ solds + ", price=" + price + ", value=" + value

+ ", address=" + address + "]";

}

}

 

}


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

阜城县| 永登县| 柞水县| 赣州市| 呼伦贝尔市| 屯门区| 靖远县| 理塘县| 宁南县| 扎赉特旗| 安国市| 大埔区| 竹溪县| 兴国县| 皮山县| 湘西| 屯昌县| 衡山县| 盐边县| 内丘县| 辽宁省| 甘肃省| 农安县| 乌鲁木齐市| 顺昌县| 贡觉县| 新疆| 莒南县| 南溪县| 子长县| 前郭尔| 环江| 宜兰市| 周至县| 合川市| 柞水县| 神木县| 横峰县| 咸宁市| 河北区| 昌宁县|