override

Handler修改子线程UI

匿名 (未验证) 提交于 2019-12-03 00:30:01
给出了个小栗子 public class MainActivity extends AppCompatActivity implements View . OnClickListener { private TextView show; public static final int UPDATE_TEXT = 1 ; private Handler handler = new Handler() { @Override public void handleMessage (Message msg) { //接收,判断,处理消息 switch (msg.what) { case UPDATE_TEXT: show.setText( "更改UI" ); break ; default : break ; } } }; @Override protected void onCreate (Bundle savedInstanceState) { super .onCreate(savedInstanceState); setContentView(R.layout.activity_main); //一个Textview,修改文字来达到模拟更改界面UI的效果 show = (TextView) findViewById(R.id.tv_show); } @Override public

Override(重写)静态方法

匿名 (未验证) 提交于 2019-12-03 00:22:01
public class OverrideDemo { public static void main(String[] args) { A pra = new B(); pra.say(); } }class A {public static void say(){System.out.println("A");}}class B extends A{public static void say(){System.out.println("B");}} 此时的输出结果是: B 但是,如果是子类类型引用指向子类类型对象时,会发现调用的还是子类的静态方法。 public static void main(String[] args) { B pra = new B(); pra.say(); } 此时的输出结果是: A 由此可以发现,当被子类的静态方法的签名和被继承的静态方法签名相同时,向上造型后子类对象只能调用父类静态方法,看起来是不符合面向对象的多态属性。 静态方法是属于类的,静态方法无法被覆盖。子类无法覆盖父类方法时,就不属于多态。 例如 A a = new B();可以翻译为,一个A类型引用a指向B类型对象。所以它还是属于父类类型,调用的静态方法也就是父类的。 文章来源: Override(重写)静态方法

策略模式

匿名 (未验证) 提交于 2019-12-03 00:19:01
策略模式 一、策略模式简介 先看一下示例,假如一个超市,在结账的时候对不同的会员进行不同的打折策略,该代码实现如下 抽象会员接口 public interface VIPCard { double sale(double money); } 普通会员不打折 public class CommonVip implements VIPCard { @Override public double sale(double money) { return 1 * money; } } 黄金会员打九折 public class GoldVip implements VIPCard{ @Override public double sale(double money) { return 0.9 * money; } } 钻石会员打八折 public class DiamondVip implements VIPCard { @Override public double sale(double money) { return 0.8 * money; } } 具体环境,超市打折计算金额 public class Shop{ private VIPCard vipCard; public Shop(VIPCard vipCard){ this.vipCard=vipCard; } public

常用底部滚动选择框

匿名 (未验证) 提交于 2019-12-03 00:18:01
效果: 代码: public class SelectDialog extends BaseDialog { private OnSelectListener selectListener; private List<SelectItemBean> dataList; private WheelVerticalView wheel_select; private TextView tv_cancel; private RelativeLayout rl_select_layout; public SelectDialog(Context context) { super(context); } public SelectDialog(Context context, List dataList, boolean canceledOnTouchOutside, OnSelectListener selectListener) { super(context, canceledOnTouchOutside); this.dataList = dataList; this.selectListener = selectListener; } @Override protected int getLayoutId() { return R.layout.dlg_select; }

okhttp加载图片

匿名 (未验证) 提交于 2019-12-03 00:18:01
public class MainActivity extends AppCompatActivity { private String path = "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1527002323765&di=a5271ae1cba8945183d3a2326ea41e6a&imgtype=0&src=http%3A%2F%2Fwww.cd-auto.net%2Fupload%2Fnews%2Fa84bf7035c1b472b976e8a145f9ba5ff%2F201710130356363704.jpg" ; private Button jiaz ; @SuppressLint ( "HandlerLeak" ) private Handler handler = new Handler (){ @Override public void handleMessage ( Message msg ) { switch ( msg . what ){ case 0 : byte [] obj = ( byte []) msg . obj ; Bitmap bitmap = BitmapFactory . decodeByteArray ( obj , 0 , obj

Flutter 创建透明的路由页面

匿名 (未验证) 提交于 2019-12-03 00:15:02
原文 import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( home: HomePage(), ); } } class HomePage extends StatefulWidget { @override _HomePageState createState() => _HomePageState(); } class _HomePageState extends State<HomePage> { @override Widget build(BuildContext context) { return Scaffold( body: Center( child: Text('home page'), ), floatingActionButton: FloatingActionButton( child: Icon(Icons.dialer_sip), onPressed: () { Navigator.of(context).push(SimpleRoute( name:

c# 创建自绘用户控件

匿名 (未验证) 提交于 2019-12-03 00:12:02
一、继承UserControl类 public class Chart : UserControl 二、定义常量、私有成员变量、属性   加入属性的修饰,可以在图形界面配置   private const int LeftPos = 60;  private int[] m_values = new int[3];  [CategoryAttribute("Chart")]   [DescriptionAttribute("已解决的事务数量")]  [DefaultValueAttribute(0)]   public int Resolved  {   get {   return m_values[0];     } set {   //对输入值进行验证 if (value < 0) {   value = 0; } m_values[0] = value; //重绘控件 Invalidate();     }   } protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); e.Graphics.Clear(Parent.BackColor); e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; //如果控件大小能显示下所有数据 if

用户信息查询系统_daoImpl

匿名 (未验证) 提交于 2019-12-03 00:03:02
package com.hopetesting.dao.impl;import com.hopetesting.dao.UserDao;import com.hopetesting.domain.User;import com.hopetesting.utils.JDBCUtils;import org.springframework.jdbc.core.BeanPropertyRowMapper;import org.springframework.jdbc.core.JdbcTemplate;import java.util.ArrayList;import java.util.List;import java.util.Map;import java.util.Set;/** * @author newcityman * @date 2019/9/7 - 21:07 */public class UserDaoImpl implements UserDao { private JdbcTemplate jdbcTemplate = new JdbcTemplate(JDBCUtils.getDataSource()); @Override public List<User> findAllUser() { String sql = "select * from user";

【R】调整ggplot图例大小

匿名 (未验证) 提交于 2019-12-02 23:57:01
图例太多时,会挤压正图,显得正图展示区域很小,这时有必要缩小图例。 ################# # 减小ggplot图例 ################# library ( ggplot2 ) p <- ggplot ( mtcars , aes ( drat , mpg , color = factor ( gear ), shape = factor ( vs ))) + geom_point ( size = 2 ) + theme_classic () + theme ( legend . position = c ( 0.1 , 0.7 )) p # Overwrite given size (2) to 0.5 (super small) p <- p + guides ( shape = guide_legend ( override . aes = list ( size = 0.5 ))) p p <- p + guides ( color = guide_legend ( override . aes = list ( size = 0.5 ))) p p <- p + theme ( legend . title = element_text ( size = 3 ), legend . text = element_text ( size = 3

RxJava2 基础使用

匿名 (未验证) 提交于 2019-12-02 21:53:52
RxJava summary 介绍订阅模式/基本语法 介绍线程切换的订阅 介绍变化操作符 背压解决方法和操作符 介绍和retrofit使用 Lambda表达式 Observable<Integer> observable = Observable.create( new ObservableOnSubscribe<Integer>() { @Override public void subscribe (ObservableEmitter<Integer> e) throws Exception { e.onNext( 1 ); e.onNext( 2 ); e.onNext( 3 ); } }); Observer observer = new Observer() { @Override public void onSubscribe (Disposable d) { } @Override public void onNext (Object value) { Log.d( ":" , value.toString()); } @Override public void onError (Throwable e) { } @Override public void onComplete () { } }; // Consumer consumer = new Consumer