android 焦点控制及运用

2023-11-09

http://gundumw100.iteye.com/blog/1779247

setFocusable()   设置view接受焦点的资格   

isFocusable()    view是否具有接受焦点的资格  

setFocusInTouchMode()      对应在触摸模式下,设置是否有焦点来响应点触的资格         
isFocusableInTouchMode()  对应在触摸模式下,view是否具有焦点的资格

强制view焦点获取,注意:这些方法都不会触发事件(onTouch,onClick等),想要触发onClick事件请调用view.performClick()
requestFocus()                                 ------ view
requestFocus(int direction)当用户在某个界面聚集焦点,参数为下面的4个
requestFocusFromTouch()    触摸模式下
  ......
requestChildFocus (View child, View focused)   ------viewGroup
1 父元素调用此方法
2 child  将要获取焦点的子元素
3 focused 现在拥有焦点的子元素

一般也可以通过 配置文件设置
View.FOCUS_LEFT     Move focus to the left
View.FOCUS_UP       Move focus up
View.FOCUS_RIGHT    Move focus to the right
View.FOCUS_DOWN     Move focus down            
代码设置实现 其实都是通过这些设置的        

isInTouchMode()    触摸模式

-------------------------------------------------------------------------------
下面的例子主要使用了requestFocus()方法使焦点在各个控件之间切换。
看下图:



最上面的弹出框是个PopupWindow,需要依次输入4个密码,为了方便快捷,当上一个文本框输入值之后,焦点自动切换到下一个文本框,当输入到最后一个文本框后,PopupWindow自动关闭,并返回4个文本框中的值,放在String[]数组中。
看代码:
Java代码 复制代码  收藏代码
  1. package com.reyo.view;  
  2.   
  3. import android.content.Context;  
  4. import android.graphics.drawable.BitmapDrawable;  
  5. import android.text.Editable;  
  6. import android.text.TextWatcher;  
  7. import android.view.View;  
  8. import android.widget.EditText;  
  9. import android.widget.ImageButton;  
  10. import android.widget.LinearLayout.LayoutParams;  
  11. import android.widget.PopupWindow;  
  12.   
  13. import com.reyo.merchant2.R;  
  14.   
  15. public class PasswordPopupWindow extends PopupWindow {  
  16.   
  17.     private Context context;  
  18.     private EditText[] texts;  
  19.     private ImageButton btn_close;  
  20.   
  21.     public PasswordPopupWindow(Context context, View view) {  
  22.         super(view, LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, true);  
  23.         this.context = context;  
  24.         this.setBackgroundDrawable(new BitmapDrawable());// 响应返回键,响应触摸周边消失  
  25.         this.setAnimationStyle(R.style.PopupAnimationFromTop);  
  26.         this.setInputMethodMode(PopupWindow.INPUT_METHOD_FROM_FOCUSABLE);  
  27.         texts = new EditText[4];  
  28.         texts[0] = (EditText) view.findViewById(R.id.et_0);  
  29.         texts[1] = (EditText) view.findViewById(R.id.et_1);  
  30.         texts[2] = (EditText) view.findViewById(R.id.et_2);  
  31.         texts[3] = (EditText) view.findViewById(R.id.et_3);  
  32.         for (int i = 0; i < texts.length; i++) {  
  33.             final int curIndex = i;  
  34.             texts[i].addTextChangedListener(new TextWatcher() {  
  35.   
  36.                 @Override  
  37.                 public void onTextChanged(CharSequence s, int start,  
  38.                         int before, int count) {  
  39.                     // TODO Auto-generated method stub  
  40.   
  41.                 }  
  42.   
  43.                 @Override  
  44.                 public void beforeTextChanged(CharSequence s, int start,  
  45.                         int count, int after) {  
  46.                     // TODO Auto-generated method stub  
  47.   
  48.                 }  
  49.   
  50.                 @Override  
  51.                 public void afterTextChanged(Editable s) {  
  52.                     // TODO Auto-generated method stub  
  53.                     int nextIndex = curIndex + 1;  
  54.                     //当输入到最后一个EditText时关闭PopupWindow  
  55.                     if (nextIndex >= texts.length) {  
  56.                         dismiss();  
  57.                         return;  
  58.                     }  
  59.                     texts[nextIndex].requestFocus();  
  60.                 }  
  61.             });  
  62.         }  
  63.   
  64.         btn_close = (ImageButton) view.findViewById(R.id.btn_close);  
  65.         btn_close.setOnClickListener(new View.OnClickListener() {  
  66.   
  67.             public void onClick(View v) {  
  68.                 // TODO Auto-generated method stub  
  69.                 dismiss();  
  70.             }  
  71.         });  
  72.   
  73.         this.setOnDismissListener(onDismissListener);  
  74.   
  75.     }  
  76.   
  77.     private OnDismissListener onDismissListener = new OnDismissListener() {  
  78.   
  79.         public void onDismiss() {  
  80.             // TODO Auto-generated method stub  
  81.             if (onCompleteListener != null) {  
  82.                 String[] text = new String[texts.length];  
  83.                 for (int i = 0; i < texts.length; i++) {  
  84.                     text[i] = texts[i].getText().toString();  
  85.                 }  
  86.                 onCompleteListener.onComplete(text);  
  87.             }  
  88.             // 清空&归位  
  89.             for (int i = 0; i < texts.length; i++) {  
  90.                 texts[i].setText("");  
  91.             }  
  92.             texts[0].requestFocus();  
  93.         }  
  94.   
  95.     };  
  96.   
  97.     private OnCompleteListener onCompleteListener;  
  98.   
  99.     public void setOnCompleteListener(OnCompleteListener onCompleteListener) {  
  100.         this.onCompleteListener = onCompleteListener;  
  101.     }  
  102.   
  103.     public interface OnCompleteListener {  
  104.         public void onComplete(String[] texts);  
  105.     }  
  106.   
  107. }  
package com.reyo.view;

import android.content.Context;
import android.graphics.drawable.BitmapDrawable;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.LinearLayout.LayoutParams;
import android.widget.PopupWindow;

import com.reyo.merchant2.R;

public class PasswordPopupWindow extends PopupWindow {

	private Context context;
	private EditText[] texts;
	private ImageButton btn_close;

	public PasswordPopupWindow(Context context, View view) {
		super(view, LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, true);
		this.context = context;
		this.setBackgroundDrawable(new BitmapDrawable());// 响应返回键,响应触摸周边消失
		this.setAnimationStyle(R.style.PopupAnimationFromTop);
		this.setInputMethodMode(PopupWindow.INPUT_METHOD_FROM_FOCUSABLE);
		texts = new EditText[4];
		texts[0] = (EditText) view.findViewById(R.id.et_0);
		texts[1] = (EditText) view.findViewById(R.id.et_1);
		texts[2] = (EditText) view.findViewById(R.id.et_2);
		texts[3] = (EditText) view.findViewById(R.id.et_3);
		for (int i = 0; i < texts.length; i++) {
			final int curIndex = i;
			texts[i].addTextChangedListener(new TextWatcher() {

				@Override
				public void onTextChanged(CharSequence s, int start,
						int before, int count) {
					// TODO Auto-generated method stub

				}

				@Override
				public void beforeTextChanged(CharSequence s, int start,
						int count, int after) {
					// TODO Auto-generated method stub

				}

				@Override
				public void afterTextChanged(Editable s) {
					// TODO Auto-generated method stub
					int nextIndex = curIndex + 1;
					//当输入到最后一个EditText时关闭PopupWindow
					if (nextIndex >= texts.length) {
						dismiss();
						return;
					}
					texts[nextIndex].requestFocus();
				}
			});
		}

		btn_close = (ImageButton) view.findViewById(R.id.btn_close);
		btn_close.setOnClickListener(new View.OnClickListener() {

			public void onClick(View v) {
				// TODO Auto-generated method stub
				dismiss();
			}
		});

		this.setOnDismissListener(onDismissListener);

	}

	private OnDismissListener onDismissListener = new OnDismissListener() {

		public void onDismiss() {
			// TODO Auto-generated method stub
			if (onCompleteListener != null) {
				String[] text = new String[texts.length];
				for (int i = 0; i < texts.length; i++) {
					text[i] = texts[i].getText().toString();
				}
				onCompleteListener.onComplete(text);
			}
			// 清空&归位
			for (int i = 0; i < texts.length; i++) {
				texts[i].setText("");
			}
			texts[0].requestFocus();
		}

	};

	private OnCompleteListener onCompleteListener;

	public void setOnCompleteListener(OnCompleteListener onCompleteListener) {
		this.onCompleteListener = onCompleteListener;
	}

	public interface OnCompleteListener {
		public void onComplete(String[] texts);
	}

}


在Activity中的用法就简单了:
Java代码 复制代码  收藏代码
  1. private PasswordPopupWindow popupWindow;  
  2.   
  3. if (popupWindow == null) {  
  4. LayoutInflater mLayoutInflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);  
  5. View popup_view = mLayoutInflater.inflate(R.layout.popup_window_password,null);  
  6. popupWindow = new PasswordPopupWindow(context, popup_view);  
  7. //                  popupWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_FROM_FOCUSABLE);  
  8.                     popupWindow.showAtLocation(container, Gravity.TOP, 00);  
  9.                     popupWindow.setOnCompleteListener(new PasswordPopupWindow.OnCompleteListener() {  
  10.   
  11.                                 @Override  
  12.                                 public void onComplete(String[] texts) {  
  13.                                     // TODO Auto-generated method stub  
  14.                                     StringBuffer sb = new StringBuffer();  
  15.                                     for (int i = 0; i < texts.length; i++) {  
  16.                                         sb.append(texts[i]);  
  17.                                     }  
  18.                                     String p=sb.toString();  
  19.                                     if(p.length()==texts.length){  
  20. //doSomethingYouWant();  
  21.                                                                         }  
  22.                                 }  
  23.                             });  
  24.                 } else {  
  25.                     if (!popupWindow.isShowing()) {  
  26.                         popupWindow.showAtLocation(container, Gravity.TOP, 00);  
  27.                     }  
  28.                 }  
  29.                 // 强制显示输入法  
  30.                 toggleSoftInput(context);  
private PasswordPopupWindow popupWindow;

if (popupWindow == null) {
LayoutInflater mLayoutInflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
View popup_view = mLayoutInflater.inflate(R.layout.popup_window_password,null);
popupWindow = new PasswordPopupWindow(context, popup_view);
//					popupWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_FROM_FOCUSABLE);
					popupWindow.showAtLocation(container, Gravity.TOP, 0, 0);
					popupWindow.setOnCompleteListener(new PasswordPopupWindow.OnCompleteListener() {

								@Override
								public void onComplete(String[] texts) {
									// TODO Auto-generated method stub
									StringBuffer sb = new StringBuffer();
									for (int i = 0; i < texts.length; i++) {
										sb.append(texts[i]);
									}
									String p=sb.toString();
									if(p.length()==texts.length){
//doSomethingYouWant();
																		}
								}
							});
				} else {
					if (!popupWindow.isShowing()) {
						popupWindow.showAtLocation(container, Gravity.TOP, 0, 0);
					}
				}
				// 强制显示输入法
				toggleSoftInput(context);


如果弹出PasswordPopupWindow后没有弹出输入法,则强制显示输入法:
Java代码 复制代码  收藏代码
  1. /** 
  2.      * 如果输入法打开则关闭,如果没打开则打开 
  3.      *  
  4.      * @param context 
  5.      */  
  6.     protected void toggleSoftInput(Context context) {  
  7.         InputMethodManager inputMethodManager = (InputMethodManager) context  
  8.                 .getSystemService(Context.INPUT_METHOD_SERVICE);  
  9.         inputMethodManager.toggleSoftInput(0,  
  10.                 InputMethodManager.HIDE_NOT_ALWAYS);  
  11.     }  
/**
	 * 如果输入法打开则关闭,如果没打开则打开
	 * 
	 * @param context
	 */
	protected void toggleSoftInput(Context context) {
		InputMethodManager inputMethodManager = (InputMethodManager) context
				.getSystemService(Context.INPUT_METHOD_SERVICE);
		inputMethodManager.toggleSoftInput(0,
				InputMethodManager.HIDE_NOT_ALWAYS);
	}


PasswordPopupWindow的布局文件popup_window_password.xml如下:
Xml代码 复制代码  收藏代码
  1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  2.     android:layout_width="match_parent"  
  3.     android:layout_height="match_parent"  
  4.     android:gravity="center_vertical"  
  5.     android:orientation="vertical"   
  6.     android:background="@color/gray1"  
  7.     >  
  8.     <ImageButton  
  9.         android:id="@+id/btn_close"  
  10.         android:layout_width="60dp"  
  11.         android:layout_height="60dp"  
  12.         android:background="@android:color/transparent"  
  13.         android:src="@drawable/bg_btn_close"  
  14.         android:scaleType="center"  
  15.         android:layout_gravity="top|right"  
  16.         />  
  17.       
  18.           
  19.       
  20.     <LinearLayout   
  21.         android:layout_width="match_parent"  
  22.         android:layout_height="wrap_content"   
  23.         android:orientation="horizontal"  
  24.         android:gravity="center"  
  25.         >  
  26.         <EditText   
  27.             android:id="@+id/et_0"  
  28.             android:layout_width="wrap_content"  
  29.             android:layout_height="wrap_content"   
  30.             android:inputType="textPassword"  
  31.             android:singleLine="true"  
  32.             android:minWidth="60dp"  
  33.             android:minHeight="60dp"  
  34.             android:maxLength="1"  
  35.             android:layout_marginLeft="10dp"  
  36.             android:layout_marginRight="10dp"  
  37.             android:gravity="center"  
  38.             android:textSize="@dimen/font_xxxbig"  
  39.             />  
  40.         <EditText   
  41.             android:id="@+id/et_1"  
  42.             android:layout_width="wrap_content"  
  43.             android:layout_height="wrap_content"   
  44.             android:inputType="textPassword"  
  45.             android:singleLine="true"  
  46.             android:minWidth="60dp"  
  47.             android:minHeight="60dp"  
  48.             android:maxLength="1"  
  49.             android:layout_marginLeft="10dp"  
  50.             android:layout_marginRight="10dp"  
  51.             android:gravity="center"  
  52.             android:textSize="@dimen/font_xxxbig"  
  53.             />  
  54.         <EditText   
  55.             android:id="@+id/et_2"  
  56.             android:layout_width="wrap_content"  
  57.             android:layout_height="wrap_content"   
  58.             android:inputType="textPassword"  
  59.             android:singleLine="true"  
  60.             android:minWidth="60dp"  
  61.             android:minHeight="60dp"  
  62.             android:maxLength="1"  
  63.             android:layout_marginLeft="10dp"  
  64.             android:layout_marginRight="10dp"  
  65.             android:gravity="center"  
  66.             android:textSize="@dimen/font_xxxbig"  
  67.             />  
  68.         <EditText   
  69.             android:id="@+id/et_3"  
  70.             android:layout_width="wrap_content"  
  71.             android:layout_height="wrap_content"   
  72.             android:inputType="textPassword"  
  73.             android:singleLine="true"  
  74.             android:minWidth="60dp"  
  75.             android:minHeight="60dp"  
  76.             android:maxLength="1"  
  77.             android:layout_marginLeft="10dp"  
  78.             android:layout_marginRight="10dp"  
  79.             android:gravity="center"  
  80.             android:textSize="@dimen/font_xxxbig"  
  81.             />  
  82.     </LinearLayout>  
  83.     <TextView  
  84.             android:layout_width="wrap_content"  
  85.             android:layout_height="wrap_content"  
  86.             android:text="请输入操作密码(该操作由服务员完成)"  
  87.             android:textColor="@color/white"  
  88.             android:textSize="@dimen/font_middle"  
  89.             android:singleLine="true"  
  90.             android:layout_margin="20dp"  
  91.             android:layout_gravity="center_horizontal"  
  92.             />  
  93. </LinearLayout>  
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center_vertical"
    android:orientation="vertical" 
    android:background="@color/gray1"
    >
    <ImageButton
        android:id="@+id/btn_close"
        android:layout_width="60dp"
        android:layout_height="60dp"
        android:background="@android:color/transparent"
        android:src="@drawable/bg_btn_close"
        android:scaleType="center"
        android:layout_gravity="top|right"
        />
    
	    
	
    <LinearLayout 
        android:layout_width="match_parent"
    	android:layout_height="wrap_content" 
   		android:orientation="horizontal"
   		android:gravity="center"
        >
        <EditText 
            android:id="@+id/et_0"
            android:layout_width="wrap_content"
    		android:layout_height="wrap_content" 
    		android:inputType="textPassword"
    		android:singleLine="true"
    		android:minWidth="60dp"
    		android:minHeight="60dp"
    		android:maxLength="1"
    		android:layout_marginLeft="10dp"
    		android:layout_marginRight="10dp"
    		android:gravity="center"
    		android:textSize="@dimen/font_xxxbig"
            />
        <EditText 
            android:id="@+id/et_1"
            android:layout_width="wrap_content"
    		android:layout_height="wrap_content" 
    		android:inputType="textPassword"
    		android:singleLine="true"
    		android:minWidth="60dp"
    		android:minHeight="60dp"
    		android:maxLength="1"
    		android:layout_marginLeft="10dp"
    		android:layout_marginRight="10dp"
    		android:gravity="center"
    		android:textSize="@dimen/font_xxxbig"
            />
        <EditText 
            android:id="@+id/et_2"
            android:layout_width="wrap_content"
    		android:layout_height="wrap_content" 
    		android:inputType="textPassword"
    		android:singleLine="true"
    		android:minWidth="60dp"
    		android:minHeight="60dp"
    		android:maxLength="1"
    		android:layout_marginLeft="10dp"
    		android:layout_marginRight="10dp"
    		android:gravity="center"
    		android:textSize="@dimen/font_xxxbig"
            />
        <EditText 
            android:id="@+id/et_3"
            android:layout_width="wrap_content"
    		android:layout_height="wrap_content" 
    		android:inputType="textPassword"
    		android:singleLine="true"
    		android:minWidth="60dp"
    		android:minHeight="60dp"
    		android:maxLength="1"
    		android:layout_marginLeft="10dp"
    		android:layout_marginRight="10dp"
    		android:gravity="center"
    		android:textSize="@dimen/font_xxxbig"
            />
    </LinearLayout>
	<TextView
	        android:layout_width="wrap_content"
	        android:layout_height="wrap_content"
	        android:text="请输入操作密码(该操作由服务员完成)"
	        android:textColor="@color/white"
	        android:textSize="@dimen/font_middle"
	        android:singleLine="true"
	        android:layout_margin="20dp"
	        android:layout_gravity="center_horizontal"
	        />
</LinearLayout>


动画文件:
Xml代码 复制代码  收藏代码
  1. <style name="PopupAnimationFromTop" parent="android:Animation"  mce_bogus="1" >  
  2.         <item name="android:windowEnterAnimation">@anim/anim_top_in</item>  
  3.         <item name="android:windowExitAnimation">@anim/anim_top_out</item>  
  4.     </style>  
<style name="PopupAnimationFromTop" parent="android:Animation"  mce_bogus="1" >
        <item name="android:windowEnterAnimation">@anim/anim_top_in</item>
        <item name="android:windowExitAnimation">@anim/anim_top_out</item>
    </style>


anim_top_in.xml
Xml代码 复制代码  收藏代码
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <set xmlns:android="http://schemas.android.com/apk/res/android">  
  3.     <translate   
  4.     android:fromYDelta="-100%p"   
  5.     android:toYDelta="0"   
  6.     android:duration="200"   
  7.     android:fillAfter="true"  
  8.     android:interpolator="@android:anim/bounce_interpolator"  
  9.     />  
  10. </set>  
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
	<translate 
	android:fromYDelta="-100%p" 
	android:toYDelta="0" 
	android:duration="200" 
	android:fillAfter="true"
	android:interpolator="@android:anim/bounce_interpolator"
	/>
</set>

anim_top_out.xml
Xml代码 复制代码  收藏代码
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <set xmlns:android="http://schemas.android.com/apk/res/android">  
  3.     <translate   
  4.     android:fromYDelta="0"   
  5.     android:toYDelta="-100%p"   
  6.     android:duration="200"  
  7.     android:fillAfter="true"  
  8.     android:interpolator="@android:anim/bounce_interpolator"  
  9.     />  
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

android 焦点控制及运用 的相关文章

  • 【Linux学习】虚拟机VMware 安装Qt5 一条龙讲解

    如何在Linux下安装Qt5呢 若已在Linux下载好安装包 可直接从第三步进行阅读 目录 第一步 下载所需版本Qt 第二步 将Qt安装包传输到Linux 第三步 Linux下安装Qt 第四步 配置 Qt 环境 本文安装版本 linux上的
  • 浅谈软件构件和软件构件测试

    什么是构件 构件也称为组件 是一个独立发布的功能部分 通过接口可以访问它的服务 其特点是 l 软件系统中具有相对独立功能 可以明确辨识 接口由契约指定 和语境有明显依赖关系 可独立部署 且多由第三方提供的可组装软件实体 l 软件构件须承载有
  • 前端导出后端文件的方法

    一般存在两种方式 1 请求接口之后 后端返回文件路径 前端直接下载 2 请求接口之后 后端以文件流的形式返回给前端 前端再下载到本地 第一种方式 window location href res request responseURL 直接
  • CVPR 2017论文

    近期在看CVPR2017的文章 顺便就把CVPR2017整理一下 分享给大家 更多的 Computer Vision的文章可以访问Computer Vision Foundation open access CVPapers Machine
  • Vue实现给按钮的点击事件绑定id参数

    当我们需要给按钮所绑定的值做出判断并记录时 eg 为答题的正确以及题号做判断 第一种情况 使用v for循环 div div 我是id div div 1 2 3 然后在 vue 的实例中就可以拿到对应的 id b index this l
  • 持久化数据&缓存数据双写一致性

    背景 缓存中数据更新一般有两个入口 数据缓存过期 数据在访问时发现缓存中无数据时重新查库然后更新至缓存 场景和问题等同于缓存查询 相关solution参考 缓存数据查询的注意事项 缓存未过期 数据库数据有变动主动更新至缓存 比较常见的场景
  • Windows+Ubuntu 22.04.1 LTS 64bit 双系统配置

    为了开发linux下的软件 花了半天的时间安装了双系统 记录一下过程方便以后重装 帮同学装 安装尽量使用官网教程 一 提前准备 1 确保硬盘有足够空余空间 2 关闭windows快速启动 会影响开机进入多系统引导 windows 10如何关
  • 函数栈帧的创建与销毁

    目录 引言 基础知识 内存模型 寄存器的种类与功能 常用的汇编指令 函数栈帧创建与销毁 main 函数栈帧的创建 NO1 NO2 NO3 NO4 NO5 NO6 main 函数栈帧变量的创建 调用Add 函数栈帧的预备工作 传参 NO1 N
  • 小蜜团队万字长文《读后简略概括》

    1 对话系统主要分为三类 闲聊型 任务导向型 问答型 闲聊型 就是瞎聊 想聊啥就 聊啥 任务导向型 考虑多轮对话 根据对话的不同状态和槽位值进行回复策略的选择 问答型 一问一答 识别询问者的意图 从知识库中选取答案进行返回 2 任务导向型
  • perl编写之前的一些习惯细节

    变量 环境变量的传递 文件 文件目录文件名路径的解析操作 命令行参数 调用shell命令 变量的debug 主体结构的划分 编写简单package的模板 脚本执行的关键信息保存在日志里 代码整理 下述信息 仅供自己编写新脚本之前的回顾内容
  • web前端html+css基础 项目实例

  • 【C++笔记】数据结构栈、堆,内存占用中栈区、堆区的区别和理解

    在计算机领域 堆栈是一个不容忽视的概念 我们编写的C语言程序基本上都要用到 但对于很多的初学着来说 堆栈是一个很模糊的概念 堆栈 一种数据结构 一个在程序运行时用于存放的地方 这可能是很多初学者的认识 因为我曾经就是这么想的和汇编语言中的堆
  • matlab机器人工具箱(1)

    1 机器人工具箱 2 Figure的基本组成 figure和axes的概念 在实际绘图中 一张图可能会有好几个子图 这时axes表示生成的各个小图 而figure则是绘制各图的大画布 所以 在之后设置图形属性时 有时用到gca Axes 有
  • Python爬虫自动刷“问卷网”问卷(不锁IP)

    大学很多项目都会要求征集问卷 但很难找到渠道迅速收集大量样本 如果是自己通过 问卷网 设计的问卷可以在设置不锁IP 默认情况 下用本方法快速刷取大量样本 且能保证问卷结果满足自身项目需求 即使没有了解过爬虫 稍有python基础看过本程序后
  • C++后台开发之我见

    C 后台开发之我见 2017 2 6 工作也快两年了 偶然看到自己以前写过的一些技术博客 发现自己自毕业后一直没有更新过自己的技术博客 趁现在是刚过完春节快要回公司工作之际 谈谈我个人对后台开发的一些个人见解 希望能够对在校的学生或者刚刚接
  • Python爬虫从入门到精通:今日作业_requests基础04_爬取药监总局中的企业详情数据_Python涛哥

    今日作业 爬取药监总局中的企业详情数据 爬取药监总局中的企业详情数据 url http scxk nmpa gov cn 81 xk 需求 将首页中每一家企业详情页对应的数据 每一家企业详情页对应的数据 将前5页企业的数据爬取即可 难点 用
  • scipy.sparse使用简例

    CDIMC Net 1 中有个对整个数据集求 kNN 图的函数 get kNNgraph2 2 是用 dense 的 numpy ndarray 存的 空间复杂度 O n 2 O n 2
  • HBuilder 制表符转换成空格

    在学习BootStrap时 看到 编码规范 by mdo 里面有一条关于编辑器配置的 用两个空格代替制表符 soft tab 即用空格代表 tab 符 避免常见的代码不一致和差异 然后找到了 HBuilder 制表符转换成空格 的方法 具体

随机推荐

  • Linux环境SVN用户权限修改

    1 查看SVN配置文件位置 系统环境 Linux 3 10 0 使用命令行查看SVN进程 ps ef grep svn 通过进程信息可以看到svnserve conf存放的目录 svnserve conf是svn配置文件 vim 目录 sv
  • OpenHarmony与HarmonyOS联系与区别

    目录 1 背景 2 OpenHarmony 3 HarmonyOS 4 鸿蒙生态 5 OpenHarmony与HarmonyOS的技术上实现区别 1 语言支持 2 SDK 的不同 3 运行调测方式不同 4 对APK的兼容性不同 5 包含关系
  • Android CheckBox 多选以及反选清除已选项

    前言 疫情随着这个春天的到来已悄然离去 你还记得填写问卷调查的那个时候么 话不多少 这篇文章要实现的就是一个问卷调查列表 即 Listview 嵌套 Listview 实现 checkbox 多选以及反选清除已选项 正文 思路就是定义一个
  • web服务选择lighttpd,采用fcgi组件技术扩展处理业务层

    目录 一 简介fcgi web和web服务器间数据传输的桥梁 2 二 源码编译配置ARM Lighttpd Fastcgi C 3 1 交叉编译 源文件都从官网下载 Fcgi lighttpd zlib 3 2 配置服务器server do
  • VMware上安装虚拟机的一些注意事项和VMware tools的安装

    VMware上安装虚拟机 VMware是windows上的一个应用程序 它可以虚拟出一个物理主机 pc机 在该虚拟机上可以安装linux系统 相关安装流程csdn上参考过多 这里不再赘述 虚拟机安装位置要求 1 不能和VMware放在同一个
  • 为AI而生的数据库:Milvus详解及实战

    1 向量数据库 1 1 向量数据库的由来 在当今数字化时代 人工智能AI正迅速改变着我们的生活和工作方式 从智能助手到自动驾驶汽车 AI正在成为各行各业的创新引擎 然而 这种AI的崛起也带来了一个关键的挑战 如何有效地处理和分析越来越丰富和
  • QSetting读取ini配置文件失败

    今天碰到一个问题 QSettings读取配置文件失败 同样的代码用5 13版本编译后读取正常 用5 7版本编译读取不到 排除了文件编码格式的问题 最终问题解决了 原因没有找到 解决方法是试错试出来的 解决方法是把相对路径换成了绝对路径 问题
  • 常见中间件漏洞复现

    目录 Tomcat 1 Tomcat 文件上传 CVE 2017 12615 2 Tomcat 代码执行 CVE 2020 1938 3 Tomcat弱口令登录获取后台 Weblogic 4 Weblogic反序列化漏洞获取服务器权限 CV
  • Vuex4(Module)+Typescript的基本使用

    一 Vuex4介绍 vuex 是一个专为 Vue js 应用程序开发的状态管理模式 库 它采用集中式存储管理应用的所有组件的状态 并以相应的规则保证状态以一种可预测的方式发生变化 vuex包括五大核心概念分别是State Getter Mu
  • Sql server 千万级大数据SQL查询优化的几点建议

    1 对查询进行优化 应尽量避免全表扫描 首先应考虑在 where 及 order by 涉及的列上建立索引 2 应尽量避免在 where 子句中对字段进行 null 值判断 否则将导致引擎放弃使用索引而进行全表扫描 如 select id
  • 应“云”而生的云数据库,让数据从“江河”到“大海”

    随着信息技术的发展 互联网应用的加速普及 人类进入了数字经济时代 进入二十一世纪以后 随着移动互联网技术 物联网技术 5G等技术的发展 全球数据圈 Global Datasphere 呈指数级递增 IDC预测全球数据将于2025年增长至17
  • [USACO Dec20 Bronze]Stuck in a Rut

    Farmer John 最近扩大了他的农场 从奶牛们的角度看来这个农场相当于是无限大了 奶牛们将农场上放牧的区域想作是一个由正方形方格组成的无限大二维方阵 每个方格中均有美味的草 将每个方格看作是棋盘上的一个方格 Farmer John 的
  • RANSAC算法实现图像全景拼接

    文章目录 一 全景拼接的原理 1 RANSAC算法介绍 2 使用RANSAC算法来求解单应性矩阵 3 拼接图像 二 全景拼接实验 1 针对固定点位拍摄多张图片 以中间图片为中心 实现图像的拼接融合 1 输入图片 2 代码 3 运行结果 4
  • 单向链表双向链表优缺点

    单向链表优缺点 1 优点 单向链表增加删除节点简单 遍历时候不会死循环 2 缺点 只能从头到尾遍历 只能找到后继 无法找到前驱 也就是只能前进 双向链表优缺点 1 优点 可以找到前驱和后继 可进可退 2 缺点 增加删除节点复杂 多需要分配一
  • 陈嘉哲:黄金原油跳水承压,日内或将延续,如何操作?附操作建议

    陈嘉哲 7 6黄金原油跳水承压 日内有望继续下行 如何操作 附操作建议 无论行情暴涨 暴跌 单边还是震荡 你是不是总是没把握住 就是所谓的一买就跌 一跌就割 一割就涨 一涨就追 一追又套 一套再割 这就像一个死套 资金不断的缩水 过程一直在
  • 银保监局315再点名元宇宙炒作,又见监管难题,立法是否当务之急

    3月15日 北京银保监局发布 理性消费不乱贷 美好青春不负债 风险提示指出 目前网络上出现一些 小游戏 假借 元宇宙 区块链 等概念进行炒作 这是继2月18日银保监会发布 关于防范以 元宇宙 名义进行非法集资的风险提示 后 监管部门再次点名
  • 6种常用开源协议介绍

    为什么要有开源协议呢 其一 保护原作者的知识成果 防止被恶意利用 开源协议中一般都包含有免责声明 可以防止原作者承担相应风险和后果 比如你开源了一个破解Windows秘钥的软件 而使用者却用来进行商业资料窃取 那么你是不需要为此承担责任的
  • vscode的eslint配置保存自动修复代码

    提示 本文展示了vue项目中配置eslint 在vscode编辑器中保存后可以自动修复 文章目录 前言 一 vscode配置 二 vue项目package json中与eslint相关的配置 总结 前言 本次配置达到的效果 vue代码格式有
  • React 性能优化指南之性能分析与16种优化方法大总结

    本文分为两个部分 1 如何分析 React性能 1 1 性能分析指标有哪些 1 2 性能分析的两个阶段 1 3 通过工具查看指标和度量 2 16个React 性能优化方法 2 1 前端通用优化 2 2 减少不必要的组件更新 2 3 提交阶段
  • android 焦点控制及运用

    http gundumw100 iteye com blog 1779247 setFocusable 设置view接受焦点的资格 isFocusable view是否具有接受焦点的资格 setFocusInTouchMode 对应在触摸模