android 隨機雲標簽(圓形)

来源:http://www.cnblogs.com/ganchuanpu/archive/2017/05/10/6838396.html
-Advertisement-
Play Games

這個適合用於選擇 用戶的一些興趣標簽,個性名片等。 用於將控制項 設置為圓形 的自定義TextView 自定義佈局 用於動態生成多個 控制項 核心類 ...


這個適合用於選擇 用戶的一些興趣標簽,個性名片等。

package com.dyl.cloudtags;  
  
import java.util.ArrayList;  
import java.util.Arrays;  
import java.util.Random;  
  
import android.app.Activity;  
import android.content.SharedPreferences;  
import android.os.Bundle;  
import android.view.View;  
import android.view.View.OnClickListener;  
import android.widget.EditText;  
import android.widget.ImageView;  
import android.widget.TextView;  
import android.widget.Toast;  
  
public class MainActivity extends Activity {  
  
    private KeywordsFlow keywordsFlow;  
    private String[] keywords;  
    public static final String SEARCH_HISTORY = "search_history";  
    private ArrayList<SearchDataPojo> searchItem;  
    private String longhistory;  
    private SharedPreferences sp;  
    private ArrayList<String> history;  
    private EditText world_shopping_search_input;  
    private TextView world_city_refresh, clear_history;  
    private ImageView toSearch;  
  
    @Override  
    protected void onCreate(Bundle savedInstanceState) {  
        super.onCreate(savedInstanceState);  
        setContentView(R.layout.activity_main);  
        initView();  
        initSearchHistory();  
        refreshTags();  
    }  
  
    private void initView() {  
        world_shopping_search_input = (EditText) findViewById(R.id.world_shopping_search_input);  
        keywordsFlow = (KeywordsFlow) findViewById(R.id.keywordsflow);  
  
        world_city_refresh = (TextView) findViewById(R.id.world_city_refresh);  
        world_city_refresh.setOnClickListener(new OnClickListener() {  
  
            @Override  
            public void onClick(View arg0) {  
                refreshTags();  
            }  
        });  
  
        clear_history = (TextView) findViewById(R.id.clear_history);  
        clear_history.setOnClickListener(new OnClickListener() {  
  
            @Override  
            public void onClick(View arg0) {  
                clearSearchHistory();  
            }  
        });  
  
        toSearch = (ImageView) findViewById(R.id.toSearch);  
        toSearch.setOnClickListener(new OnClickListener() {  
  
            @Override  
            public void onClick(View arg0) {  
                saveSearchHistory();  
                refreshTags();  
            }  
        });  
    }  
  
    private void refreshTags() {  
        initSearchHistory();  
        keywordsFlow.setDuration(800l);  
        keywordsFlow.setOnItemClickListener(new OnClickListener() {  
  
            @Override  
            public void onClick(View v) {  
                String keyword = ((TextView) v).getText().toString();// 獲得點擊的標簽  
                world_shopping_search_input.setText(keyword);  
            }  
        });  
        // 添加  
        feedKeywordsFlow(keywordsFlow, keywords);  
        keywordsFlow.go2Show(KeywordsFlow.ANIMATION_IN);  
    }  
  
    private static void feedKeywordsFlow(KeywordsFlow keywordsFlow, String[] arr) {  
        Random random = new Random();  
        for (int i = 0; i < KeywordsFlow.MAX; i++) {  
            int ran = random.nextInt(arr.length);  
            String tmp = arr[ran];  
            keywordsFlow.feedKeyword(tmp);  
        }  
    }  
  
    /** 
     * 讀取歷史搜索記錄 
     */  
    private void initSearchHistory() {  
        sp = getSharedPreferences(MainActivity.SEARCH_HISTORY, 0);  
        longhistory = sp.getString(MainActivity.SEARCH_HISTORY, "");  
        if (!longhistory.equals("")) {  
            keywords = longhistory.split(",");  
            searchItem = new ArrayList<SearchDataPojo>();  
            for (int i = 0; i < keywords.length; i++) {  
                searchItem.add(new SearchDataPojo().setContent(keywords[i]));  
            }  
        } else {// 如果SharedPreferences沒有值得話,就顯示預設的數據  
            keywords = new String[] { "口味蝦", "牛蛙", "火鍋", "真功夫", "料理",  
                    "密室逃", "天成房", "波比艾" };  
        }  
    }  
  
    /* 
     * 保存搜索記錄 
     */  
    private void saveSearchHistory() {  
        String text = world_shopping_search_input.getText().toString().trim();  
        Toast.makeText(this, text, Toast.LENGTH_LONG).show();  
        if (!text.equals("") && text != null) {  
            if (text.length() < 1) {  
                return;  
            }  
            sp = getSharedPreferences(SEARCH_HISTORY, 0);  
            String longhistory = sp.getString(SEARCH_HISTORY, "");  
            String[] tmpHistory = longhistory.split(",");  
            history = new ArrayList<String>(Arrays.asList(tmpHistory));  
            if (history.size() > 0) {  
                int i;  
                for (i = 0; i < history.size(); i++) {  
                    if (text.equals(history.get(i))) {  
                        history.remove(i);  
                        break;  
                    }  
                }  
                history.add(0, text);  
            }  
            if (history.size() > 0) {  
                StringBuilder sb = new StringBuilder();  
                for (int i = 0; i < history.size(); i++) {  
                    sb.append(history.get(i) + ",");  
                }  
                sp.edit().putString(SEARCH_HISTORY, sb.toString()).commit();  
            } else {  
                sp.edit().putString(SEARCH_HISTORY, text + ",").commit();  
            }  
            clear_history.setVisibility(View.VISIBLE);  
        }  
    }  
  
    // 清除歷史數據  
    private void clearSearchHistory() {  
        searchItem.removeAll(searchItem);  
        sp.edit().clear().commit();  
        Toast.makeText(this, "清除歷史記錄", Toast.LENGTH_LONG).show();  
    }  
}  


用於將控制項 設置為圓形 的自定義TextView

package com.dyl.cloudtags;  
  
import android.content.Context;  
import android.graphics.Canvas;  
import android.graphics.Color;  
import android.graphics.Paint;  
import android.graphics.PaintFlagsDrawFilter;  
import android.util.AttributeSet;  
import android.widget.TextView;  
  
public class CircleView extends TextView {  
  
    private Paint mBgPaint = new Paint();  
  
    PaintFlagsDrawFilter pfd = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG|Paint.FILTER_BITMAP_FLAG);   
  
    public CircleView(Context context, AttributeSet attrs, int defStyle) {  
        super(context, attrs, defStyle);  
        // TODO Auto-generated constructor stub  
    }  
  
    public CircleView(Context context, AttributeSet attrs) {  
        super(context, attrs);  
        // TODO Auto-generated constructor stub  
        mBgPaint.setColor(Color.WHITE);  
        mBgPaint.setAntiAlias(true);  
    }  
  
    public CircleView(Context context) {  
        super(context);  
        // TODO Auto-generated constructor stub  
        mBgPaint.setColor(Color.WHITE);  
        mBgPaint.setAntiAlias(true);  
    }  
  
    @Override  
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {  
        // TODO Auto-generated method stub  
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);  
        int measuredWidth = getMeasuredWidth();  
        int measuredHeight = getMeasuredHeight();  
        int max = Math.max(measuredWidth, measuredHeight);  
        setMeasuredDimension(max, max);  
    }  
  
    @Override  
    public void setBackgroundColor(int color) {  
        // TODO Auto-generated method stub  
        mBgPaint.setColor(color);  
    }  
  
    /** 
     * 設置通知個數顯示 
     * @param text 
     */  
    public void setNotifiText(int text){  
        //      if(text>99){  
        //          String string = 99+"+";  
        //          setText(string);  
        //          return;  
        //      }  
        setText(text+"");  
    }  
  
    @Override  
    public void draw(Canvas canvas) {  
        // TODO Auto-generated method stub  
        canvas.setDrawFilter(pfd);  
        canvas.drawCircle(getWidth()/2, getHeight()/2, Math.max(getWidth(), getHeight())/2, mBgPaint);  
        super.draw(canvas);  
    }  
}  

  

自定義佈局 用於動態生成多個 控制項  核心類

package com.dyl.cloudtags;  
  
import java.util.LinkedList;  
import java.util.Random;  
import java.util.Vector;  
import android.content.Context;  
import android.graphics.Color;  
import android.graphics.Paint;  
import android.graphics.drawable.GradientDrawable;  
import android.util.AttributeSet;  
import android.view.Gravity;  
import android.view.LayoutInflater;  
import android.view.View;  
import android.view.ViewTreeObserver.OnGlobalLayoutListener;  
import android.view.animation.AlphaAnimation;  
import android.view.animation.Animation;  
import android.view.animation.Animation.AnimationListener;  
import android.view.animation.AnimationSet;  
import android.view.animation.AnimationUtils;  
import android.view.animation.Interpolator;  
import android.view.animation.ScaleAnimation;  
import android.view.animation.TranslateAnimation;  
import android.widget.FrameLayout;  
  
public class KeywordsFlow extends FrameLayout implements OnGlobalLayoutListener {  
  
    public static final int IDX_X = 0;  
    public static final int IDX_Y = 1;  
    public static final int IDX_TXT_LENGTH = 2;  
    public static final int IDX_DIS_Y = 3;  
    /** 由外至內的動畫。 */  
    public static final int ANIMATION_IN = 1;  
    /** 由內至外的動畫。 */  
    public static final int ANIMATION_OUT = 2;  
    /** 位移動畫類型:從外圍移動到坐標點。 */  
    public static final int OUTSIDE_TO_LOCATION = 1;  
    /** 位移動畫類型:從坐標點移動到外圍。 */  
    public static final int LOCATION_TO_OUTSIDE = 2;  
    /** 位移動畫類型:從中心點移動到坐標點。 */  
    public static final int CENTER_TO_LOCATION = 3;  
    /** 位移動畫類型:從坐標點移動到中心點。 */  
    public static final int LOCATION_TO_CENTER = 4;  
    public static final long ANIM_DURATION = 800l;  
    public static final int MAX = 12;  
    public static final int TEXT_SIZE_MAX = 20;  
    public static final int TEXT_SIZE_MIN = 10;  
    private OnClickListener itemClickListener;  
    private static Interpolator interpolator;  
    private static AlphaAnimation animAlpha2Opaque;  
    private static AlphaAnimation animAlpha2Transparent;  
    private static ScaleAnimation animScaleLarge2Normal, animScaleNormal2Large,  
            animScaleZero2Normal, animScaleNormal2Zero;  
    /** 存儲顯示的關鍵字。 */  
    private Vector<String> vecKeywords;  
    private int width, height;  
    /** 
     * go2Show()中被賦值為true,標識開發人員觸發其開始動畫顯示。<br/> 
     * 本標識的作用是防止在填充keywrods未完成的過程中獲取到width和height後提前啟動動畫。<br/> 
     * 在show()方法中其被賦值為false。<br/> 
     * 真正能夠動畫顯示的另一必要條件:width 和 height不為0。<br/> 
     */  
    private boolean enableShow;  
    private Random random;  
  
    private int txtAnimInType, txtAnimOutType;  
    /** 最近一次啟動動畫顯示的時間。 */  
    private long lastStartAnimationTime;  
    /** 動畫運行時間。 */  
    private long animDuration;  
    private Context context;  
    public KeywordsFlow(Context context) {  
        super(context);  
        init();  
    }  
  
    public KeywordsFlow(Context context, AttributeSet attrs) {  
        super(context, attrs);  
        init();  
    }  
  
    public KeywordsFlow(Context context, AttributeSet attrs, int defStyle) {  
        super(context, attrs, defStyle);  
        init();  
    }  
  
    private void init() {  
        lastStartAnimationTime = 0l;  
        animDuration = ANIM_DURATION;  
        random = new Random();  
        vecKeywords = new Vector<String>(MAX);  
        getViewTreeObserver().addOnGlobalLayoutListener(this);  
        interpolator = AnimationUtils.loadInterpolator(getContext(),  
                android.R.anim.decelerate_interpolator);  
        animAlpha2Opaque = new AlphaAnimation(0.0f, 1.0f);  
        animAlpha2Transparent = new AlphaAnimation(1.0f, 0.0f);  
        animScaleLarge2Normal = new ScaleAnimation(2, 1, 2, 1);  
        animScaleNormal2Large = new ScaleAnimation(1, 2, 1, 2);  
        animScaleZero2Normal = new ScaleAnimation(0, 1, 0, 1);  
        animScaleNormal2Zero = new ScaleAnimation(1, 0, 1, 0);  
    }  
  
    public long getDuration() {  
        return animDuration;  
    }  
  
    public void setDuration(long duration) {  
        animDuration = duration;  
    }  
  
    public boolean feedKeyword(String keyword) {  
        boolean result = false;  
        if (vecKeywords.size() < MAX) {  
            result = vecKeywords.add(keyword);  
        }  
        return result;  
    }  
  
    /** 
     * 開始動畫顯示。<br/> 
     * 之前已經存在的TextView將會顯示退出動畫。<br/> 
     *  
     * @return 正常顯示動畫返回true;反之為false。返回false原因如下:<br/> 
     *         1.時間上不允許,受lastStartAnimationTime的制約;<br/> 
     *         2.未獲取到width和height的值。<br/> 
     */  
    public boolean go2Show(int animType) {  
        if (System.currentTimeMillis() - lastStartAnimationTime > animDuration) {  
            enableShow = true;  
            if (animType == ANIMATION_IN) {  
                txtAnimInType = OUTSIDE_TO_LOCATION;  
                txtAnimOutType = LOCATION_TO_CENTER;  
            } else if (animType == ANIMATION_OUT) {  
                txtAnimInType = CENTER_TO_LOCATION;  
                txtAnimOutType = LOCATION_TO_OUTSIDE;  
            }  
            disapper();  
            boolean result = show();  
            return result;  
        }  
        return false;  
    }  
  
    private void disapper() {  
        int size = getChildCount();  
        for (int i = size - 1; i >= 0; i--) {  
            final CircleView txv = (CircleView) getChildAt(i);  
            if (txv.getVisibility() == View.GONE) {  
                removeView(txv);  
                continue;  
            }  
            FrameLayout.LayoutParams layParams = (LayoutParams) txv  
                    .getLayoutParams();  
            int[] xy = new int[] { layParams.leftMargin, layParams.topMargin,  
                    txv.getWidth() };  
            AnimationSet animSet = getAnimationSet(xy, (width >> 1),  
                    (height >> 1), txtAnimOutType);  
            txv.startAnimation(animSet);  
            animSet.setAnimationListener(new AnimationListener() {  
                public void onAnimationStart(Animation animation) {  
                }  
  
                public void onAnimationRepeat(Animation animation) {  
                }  
  
                public void onAnimationEnd(Animation animation) {  
                    txv.setOnClickListener(null);  
                    txv.setClickable(false);  
                    txv.setVisibility(View.GONE);  
                }  
            });  
        }  
    }  
  
    private boolean show() {  
        if (width > 0 && height > 0 && vecKeywords != null  
                && vecKeywords.size() > 0 && enableShow) {  
            enableShow = false;  
            lastStartAnimationTime = System.currentTimeMillis();  
            int xCenter = width >> 1, yCenter = height >> 1;  
            int size = vecKeywords.size();  
            int xItem = width / size, yItem = height / size;  
            LinkedList<Integer> listX = new LinkedList<Integer>(), listY = new LinkedList<Integer>();  
            for (int i = 0; i < size; i++) {  
                // 準備隨機候選數,分別對應x/y軸位置  
                listX.add(i * xItem);  
                listY.add(i * yItem + (yItem >> 2));  
            }  
            LinkedList<CircleView> listTxtTop = new LinkedList<CircleView>();  
            LinkedList<CircleView> listTxtBottom = new LinkedList<CircleView>();  
            for (int i = 0; i < size; i++) {  
                String keyword = vecKeywords.get(i);  
                // 隨機位置,糙值  
                int xy[] = randomXY(random, listX, listY, xItem);  
                // 實例化TextView  
                final CircleView txv = new CircleView(getContext());  
                txv.setBackgroundResource(R.drawable.text_view_border);  
                txv.setGravity(Gravity.CENTER);  
                txv.setOnClickListener(itemClickListener);  
                txv.setText(keyword);  
                txv.setTextColor(Color.WHITE);  
                txv.setPadding(8, 6, 8, 6);  
                txv.setSingleLine(true);  
                int r = random.nextInt(256);  
                int g= random.nextInt(256);  
                int b = random.nextInt(256);  
                int mColor = Color.rgb(r, g, b);   
                GradientDrawable myGrad = (GradientDrawable)txv.getBackground();  
                myGrad.setColor(mColor);  
//              txv.setBackgroundColor(mColor);  
                // 獲取文本長度  
                Paint paint = txv.getPaint();  
                int strWidth = (int) Math.ceil(paint.measureText(keyword));  
                xy[IDX_TXT_LENGTH] = strWidth;  
                // 第一次修正:修正x坐標  
                if (xy[IDX_X] + strWidth > width - (xItem >> 1)) {  
                    int baseX = width - strWidth;  
                    // 減少文本右邊緣一樣的概率  
                    xy[IDX_X] = baseX - xItem + random.nextInt(xItem >> 1);  
                } else if (xy[IDX_X] == 0) {  
                    // 減少文本左邊緣一樣的概率  
                    xy[IDX_X] = Math.max(random.nextInt(xItem), xItem / 3);  
                }  
                xy[IDX_DIS_Y] = Math.abs(xy[IDX_Y] - yCenter);  
                txv.setTag(xy);  
                if (xy[IDX_Y] > yCenter) {  
                    listTxtBottom.add(txv);  
                } else {  
                    listTxtTop.add(txv);  
                }  
            }  
            attach2Screen(listTxtTop, xCenter, yCenter, yItem);  
            attach2Screen(listTxtBottom, xCenter, yCenter, yItem);  
            return true;  
        }  
        return false;  
    }  
  
    /** 修正TextView的Y坐標將將其添加到容器上。 */  
    private void attach2Screen(LinkedList<CircleView> listTxt, int xCenter,  
            int yCenter, int yItem) {  
        int size = listTxt.size();  
        sortXYList(listTxt, size);  
        for (int i = 0; i < size; i++) {  
            CircleView txv = listTxt.get(i);  
            int[] iXY = (int[]) txv.getTag();  
            // 第二次修正:修正y坐標  
            int yDistance = iXY[IDX_Y] - yCenter;  
            // 對於最靠近中心點的,其值不會大於yItem<br/>  
            // 對於可以一路下降到中心點的,則該值也是其應調整的大小<br/>  
            int yMove = Math.abs(yDistance);  
            inner: for (int k = i - 1; k >= 0; k--) {  
                int[] kXY = (int[]) listTxt.get(k).getTag();  
                int startX = kXY[IDX_X];  
                int endX = startX + kXY[IDX_TXT_LENGTH];  
                // y軸以中心點為分隔線,在同一側  
                if (yDistance * (kXY[IDX_Y] - yCenter) > 0) {  
                    if (isXMixed(startX, endX, iXY[IDX_X], iXY[IDX_X]  
                            + iXY[IDX_TXT_LENGTH])) {  
                        int tmpMove = Math.abs(iXY[IDX_Y] - kXY[IDX_Y]);  
                        if (tmpMove > yItem) {  
                            yMove = tmpMove;  
                        } else if (yMove > 0) {  
                            // 取消預設值。  
                            yMove = 0;  
                        }  
                        break inner;  
                    }  
                }  
            }  
            if (yMove > yItem) {  
                int maxMove = yMove - yItem;  
                int randomMove = random.nextInt(maxMove);  
                int realMove = Math.max(randomMove, maxMove >> 1) * yDistance  
                        / Math.abs(yDistance);  
                iXY[IDX_Y] = iXY[IDX_Y] - realMove;  
                iXY[IDX_DIS_Y] = Math.abs(iXY[IDX_Y] - yCenter);  
                // 已經調整過前i個需要再次排序  
                sortXYList(listTxt, i + 1);  
            }  
            FrameLayout.LayoutParams layParams = new FrameLayout.LayoutParams(  
                    FrameLayout.LayoutParams.WRAP_CONTENT,  
                    FrameLayout.LayoutParams.WRAP_CONTENT);  
            layParams.gravity = Gravity.LEFT | Gravity.TOP;  
            layParams.leftMargin = iXY[IDX_X];  
            layParams.topMargin = iXY[IDX_Y];  
            addView(txv, layParams);  
            // 動畫  
            AnimationSet animSet = getAnimationSet(iXY, xCenter, yCenter,  
                    txtAnimInType);  
            txv.startAnimation(animSet);  
        }  
    }  
  
    public AnimationSet getAnimationSet(int[] xy, int xCenter, int yCenter,  
            int type) {  
        AnimationSet animSet = new AnimationSet(true);  
        animSet.setInterpolator(interpolator);  
        if (type == OUTSIDE_TO_LOCATION) {  
            animSet.addAnimation(animAlpha2Opaque);  
            animSet.addAnimation(animScaleLarge2Normal);  
            TranslateAnimation translate = new TranslateAnimation((xy[IDX_X]  
                    + (xy[IDX_TXT_LENGTH] >> 1) - xCenter) << 1, 0,  
                    (xy[IDX_Y] - yCenter) << 1, 0);  
            animSet.addAnimation(translate);  
        } else if (type == LOCATION_TO_OUTSIDE) {  
            animSet.addAnimation(animAlpha2Transparent);  
            animSet.addAnimation(animScaleNormal2Large);  
            TranslateAnimation translate = new TranslateAnimation(0, (xy[IDX_X]  
                    + (xy[IDX_TXT_LENGTH] >> 1) - xCenter) << 1, 0,  
                    (xy[IDX_Y] - yCenter) << 1);  
            animSet.addAnimation(translate);  
        } else if (type == LOCATION_TO_CENTER) {  
            animSet.addAnimation(animAlpha2Transparent);  
            animSet.addAnimation(animScaleNormal2Zero);  
            TranslateAnimation translate = new TranslateAnimation(0,  
                    (-xy[IDX_X] + xCenter), 0, (-xy[IDX_Y] + yCenter));  
            animSet.addAnimation(translate);  
        } else if (type == CENTER_TO_LOCATION) {  
            animSet.addAnimation(animAlpha2Opaque);  
            animSet.addAnimation(animScaleZero2Normal);  
            TranslateAnimation translate = new TranslateAnimation(  
                    (-xy[IDX_X] + xCenter), 0, (-xy[IDX_Y] + yCenter), 0);  
            animSet.addAnimation(translate);  
        }  
        animSet.setDuration(animDuration);  
        return animSet;  
    }  
  
    /** 
     * 根據與中心點的距離由近到遠進行冒泡排序。 
     *  
     * @param endIdx 
     *            起始位置。 
     * @param txtArr 
     *            待排序的數組。 
     *  
     */  
    private void sortXYList(LinkedList<CircleView> listTxt, int endIdx) {  
        for (int i = 0; i < endIdx; i++) {  
            for (int k = i + 1; k < endIdx; k++) {  
                if (((int[]) listTxt.get(k).getTag())[IDX_DIS_Y] < ((int[]) listTxt  
                        .get(i).getTag())[IDX_DIS_Y]) {  
                    CircleView iTmp = listTxt.get(i);  
                    CircleView kTmp = listTxt.get(k);  
                    listTxt.set(i, kTmp);  
                    listTxt.set(k, iTmp);  
                }  
            }  
        }  
    }  
  
    /** A線段與B線段所代表的直線在X軸映射上是否有交集。 */  
    private boolean isXMixed(int startA, int endA, int startB, int endB) {  
        boolean result = false;  
        if (startB >= startA && startB <= endA) {  
            result = true;  
        } else if (endB >= startA && endB <= endA) {  
            result = true;  
        } else if (startA >= startB && startA <= endB) {  
            result = true;  
        } else if (endA >= startB && endA <= endB) {  
            result = true;  
        }  
        return result;  
    }  
  
    //得到隨機坐標  
    private int[] randomXY(Random ran, LinkedList<Integer> listX,  
            LinkedList<Integer> listY, int xItem) {  
        int[] arr = new int[4];  
        arr[IDX_X] = listX.remove(ran.nextInt(listX.size()));  
        arr[IDX_Y] = listY.remove(ran.nextInt(listY.size()));  
        return arr;  
    }  
  
    public void onGlobalLayout() {  
        int tmpW = getWidth();  
        int tmpH = getHeight();  
        if (width != tmpW || height != tmpH) {  
            width = tmpW;  
            height = tmpH;  
            show();  
        }  
    }  
  
    public Vector<String> getKeywords() {  
        return vecKeywords;  
    }  
  
    public void rubKeywords() {  
      &nb

您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • history.go(-n) 返回上一頁(n 為返回前幾頁) window.location.reload(); 刷新當前頁面 history.go(-1);window.locatoin.reload(); 等效於 self.location = document.referrer 返回上一頁並刷 ...
  • 摘錄自 "《CSS核心技術詳解》" 1.1 CSS中你可能會疑問的幾個問題 1.1.1 在CSS中為什麼要有層疊 在CSS中可能會有多個樣式表同時影響同一個元素的某個屬性,設計這個功能的主要原因有兩個,解決模塊化和作者、用戶、用戶代理樣式衝突。 模塊化 一個頁面中的樣式可以拆分成多個樣式表,代碼如下 ...
  • 前言 Promise的重要性我認為我沒有必要多講,概括起來說就是必須得掌握,而且還要掌握透徹。這篇文章的開頭,主要跟大家分析一下,為什麼會有Promise出現。 在實際的使用當中,有非常多的應用場景我們不能立即知道應該如何繼續往下執行。最重要也是最主要的一個場景就是ajax請求。通俗來說,由於網速的 ...
  • 此篇為針對ios中的UI基礎知識,為了能讓大家更清楚的理解,此整理中編寫了採用知識點+案例的方式,配有非常詳細的截圖和代碼註釋,添加了許多大白話進行解釋,如有錯誤之處,望指正,願與您相互交流學習,共同進步!---"會飛的猴子_阿新"本篇案例修改圖為(後面會逐步優化細節問題)主要內容從支付寶案例開始,... ...
  • 轉載請註明http://www.cnblogs.com/igoslly/p/6838991.html 【類】的設定與繼承 當設置相同格式的TextView時,已提出在styles.xml自定義格式統一TextView格式,類似【類】即為自定義方法來統一同類型的變數。 1、定義【類】 圖設置了一個名為 ...
  • 1. 單關鍵字匹配 若只需匹配 搜索內容 可以寫的簡單一些,代碼如下: 上面的name是你要顯示整個item內容, mKeyWord 是搜索的關鍵字 holder.tv_name 是當前textview控制項 2.多關鍵字匹配 有的時候我們做搜索的時候 是需要將用戶輸入的關鍵字在服務端做拆分,拆分為多 ...
  • 自定義 用法如下: ...
  • 1.導致Fragment 重疊 和遮蓋的原因 主要還是因為Fragment的狀態保存機制,當系統記憶體不足時,Fragment的主Activity被回收,Fragment的實例並沒有隨之被回收。 Activity被系統回收時,會主動調用onSaveInstance()方法來保存視圖層(View Hie ...
一周排行
    -Advertisement-
    Play Games
  • 前言 本文介紹一款使用 C# 與 WPF 開發的音頻播放器,其界面簡潔大方,操作體驗流暢。該播放器支持多種音頻格式(如 MP4、WMA、OGG、FLAC 等),並具備標記、實時歌詞顯示等功能。 另外,還支持換膚及多語言(中英文)切換。核心音頻處理採用 FFmpeg 組件,獲得了廣泛認可,目前 Git ...
  • OAuth2.0授權驗證-gitee授權碼模式 本文主要介紹如何筆者自己是如何使用gitee提供的OAuth2.0協議完成授權驗證並登錄到自己的系統,完整模式如圖 1、創建應用 打開gitee個人中心->第三方應用->創建應用 創建應用後在我的應用界面,查看已創建應用的Client ID和Clien ...
  • 解決了這個問題:《winForm下,fastReport.net 從.net framework 升級到.net5遇到的錯誤“Operation is not supported on this platform.”》 本文內容轉載自:https://www.fcnsoft.com/Home/Sho ...
  • 國內文章 WPF 從裸 Win 32 的 WM_Pointer 消息獲取觸摸點繪製筆跡 https://www.cnblogs.com/lindexi/p/18390983 本文將告訴大家如何在 WPF 裡面,接收裸 Win 32 的 WM_Pointer 消息,從消息裡面獲取觸摸點信息,使用觸摸點 ...
  • 前言 給大家推薦一個專為新零售快消行業打造了一套高效的進銷存管理系統。 系統不僅具備強大的庫存管理功能,還集成了高性能的輕量級 POS 解決方案,確保頁面載入速度極快,提供良好的用戶體驗。 項目介紹 Dorisoy.POS 是一款基於 .NET 7 和 Angular 4 開發的新零售快消進銷存管理 ...
  • ABP CLI常用的代碼分享 一、確保環境配置正確 安裝.NET CLI: ABP CLI是基於.NET Core或.NET 5/6/7等更高版本構建的,因此首先需要在你的開發環境中安裝.NET CLI。這可以通過訪問Microsoft官網下載並安裝相應版本的.NET SDK來實現。 安裝ABP ...
  • 問題 問題是這樣的:第三方的webapi,需要先調用登陸介面獲取Cookie,訪問其它介面時攜帶Cookie信息。 但使用HttpClient類調用登陸介面,返回的Headers中沒有找到Cookie信息。 分析 首先,使用Postman測試該登陸介面,正常返回Cookie信息,說明是HttpCli ...
  • 國內文章 關於.NET在中國為什麼工資低的分析 https://www.cnblogs.com/thinkingmore/p/18406244 .NET在中國開發者的薪資偏低,主要因市場需求、技術棧選擇和企業文化等因素所致。歷史上,.NET曾因微軟的閉源策略發展受限,儘管後來推出了跨平臺的.NET ...
  • 在WPF開發應用中,動畫不僅可以引起用戶的註意與興趣,而且還使軟體更加便於使用。前面幾篇文章講解了畫筆(Brush),形狀(Shape),幾何圖形(Geometry),變換(Transform)等相關內容,今天繼續講解動畫相關內容和知識點,僅供學習分享使用,如有不足之處,還請指正。 ...
  • 什麼是委托? 委托可以說是把一個方法代入另一個方法執行,相當於指向函數的指針;事件就相當於保存委托的數組; 1.實例化委托的方式: 方式1:通過new創建實例: public delegate void ShowDelegate(); 或者 public delegate string ShowDe ...