小编Ann*_*nna的帖子

如何从TextView获取fontFamily名称?

我想从代码中的xml获取字体系列名称attr name.例如,我有自定义textView类:

public class TextVieww extends TextView{

    public TextVieww(Context context) {
        super(context);
    }
    public TextVieww(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
    public TextVieww(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }
    public void init(Context mContext ,TextView view) {
    }
}
Run Code Online (Sandbox Code Playgroud)

XML:

 <com.typefacetest.TextVieww
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="30sp"
        android:textStyle="bold"
        android:fontFamily="sans-serif-thin"
        android:text="Hello World!" />
Run Code Online (Sandbox Code Playgroud)

我想从textView.class获得"sans-serif-thin".这个有可能?以及如何做到这一点?谢谢

android textview android-typeface

8
推荐指数
1
解决办法
2741
查看次数

从ArrayList过滤数据的最快方法是什么?

如何从ArrayList过滤数据?例如,我有一个名为"日期名称"的类.我从下面的代码中写了一些我的解释:

    public class DateAndNames {

        int day;
        int month;
        int year;
        String name;

        public DateAndNames(int day, int month, int year, String name) {
            super();
            this.day = day;
            this.month = month;
            this.year = year;
            this.name = name;
        }
        public int getDay() {
            return day;
        }
...getters and setters...
Run Code Online (Sandbox Code Playgroud)

我填充到这样的数据库:

DbHandler hand = new DbHandler(this);
hand.add(new DateAndNames(20, 3, 2008, "Jhon"));
hand.add(new DateAndNames(10, 3, 2008, "Jhon"));
hand.add(new DateAndNames(10, 2, 2004, "Jhon"));
hand.add(new DateAndNames(22, 3, 2008, "Jhon"));
Run Code Online (Sandbox Code Playgroud)

然后我得到数据到ArrayList:

ArrayList<DateAndNames> list = new ArrayList<DateAndNames>();
list …
Run Code Online (Sandbox Code Playgroud)

java android arraylist

6
推荐指数
1
解决办法
871
查看次数

如何暂停和取消暂停游戏中的线程?

我是开发游戏的新手,我试图开发一个简单的射击空间游戏,一切都很完美.现在,我想在用户点击后退按钮时创建一个Dialog弹出窗口,游戏应该暂停,直到用户按下简历.游戏暂停但是当我点击恢复按钮时,游戏仍然暂停在这里是我的游戏循环类:

public class Game extends SurfaceView implements Runnable , SurfaceHolder.Callback {

    public static  MyPreferences pref;
    public static Levels level;
    public static int SCREEN_W;
    public static int SCREEN_H;
    public static  boolean running;
    private static Thread thread = null;
    private SurfaceHolder holder;
    private Canvas canvas;
    private Paint p = new Paint();
    public static Handler handler = new Handler();
    public static Resources res;
    public static Timer timer;






    public Game(Context context) {
        super(context);
        res = getResources();
        holder = getHolder();
        holder.addCallback(this);

        level = new Levels(); …
Run Code Online (Sandbox Code Playgroud)

java multithreading android

3
推荐指数
1
解决办法
970
查看次数

设备重启后如何注册Geofence?

我在我设置的位置构建了一个弹出通知的应用程序.一切顺利.即使在我重新启动设备之后.没有问题.但我注意到,如果我关闭GPS然后重新启动我的设备,BroadcastReceiver可能会尝试登录Geofence api并因为没有GPS而收到错误.并且Geofence通知不再弹出,直到我用gps on mode重新启动我的设备.我必须使用AlarmManager吗?为了推动每x次刷新一次?要验证GPS模式是否已开启?

gps android android-geofence

3
推荐指数
1
解决办法
872
查看次数

“core.longpaths”的数字配置值“tru”错误:单位无效

我无法在 sourcetree 上启动存储库。

我得到:

bad numeric config value 'tru' for 'core.longpaths': invalid unit
Run Code Online (Sandbox Code Playgroud)

这是在我尝试克隆一个具有长文件名的项目后发生的。
然后我尝试启用“ core.longpaths”。

请问如何解决?

git sourcetree

3
推荐指数
1
解决办法
4791
查看次数

如何替换List <interface>中的值

我想替换List中显示名称中的所有逗号,我该怎么办?

 for (int i = 0; i < contacts.size(); i++) {
                if(contacts.get(i).getDisplayName().contains(",")){
                    contacts.get(i).getDisplayName().replace("," , " " );
                    contacts.notify();
                }
            }
Run Code Online (Sandbox Code Playgroud)

java android

2
推荐指数
1
解决办法
87
查看次数

如何从android上的WebView中删除<header>?

我想在webView上显示推特网站.如何删除/解除/隐藏标题("打开应用程序"消息)?

<header class="CoreLayout-header" role="banner"><div class=" AppHeader"><div class="OpenInAppBar u-cf" jsnamespace="OpenInAppBar"><div class="u-containerWithGutter"><a href="twitter://user?screen_name=nba" jsaction="click:openApp" class="OpenInAppBar-link u-textSmall u-inlineBlock">Open application</a><button class="OpenInAppBar-dismiss u-floatRight" aria-label="?????" jsaction="click:snooze" type="button"><span class="OpenInAppBar-dismissIcon u-alignMiddle Icon Icon--close" role="presentation"><img src="data:image/gif;base64,R0lGODlhFwAkAIAAAP///////yH5BAEKAAEALAAAAAAXACQAAAIbjI+py+0Po5y02ouz3rz7D4biSJbmiabqyjIFADs="><svg viewBox="0 0 46 72"><use fill="currentcolor" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/i/rw/svg/c25636093d431d0e28be32cd59239cf6/icon#icon-close"></use></svg></span></button></div></div><div class=" AppBar u-cf" data-scribe-component="top_bar" jsnamespace="AppBar"><div class="u-containerWithGutter"><h1 class="u-floatLeft"><a class="AppBar-item" aria-label="Twitter" href="/" jsaction="homeNav"><span class="AppBar-icon Icon Icon--twitter" role="presentation"><img src="data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="><svg viewBox="0 0 72 72"><use fill="currentcolor" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/i/rw/svg/c25636093d431d0e28be32cd59239cf6/icon#icon-twitter"></use></svg></span></a></h1><div class="u-floatRight"><a class="AppBar-search AppBar-item" aria-label="????? ???????" href="/search" role="search" jsaction="search"><span class="AppBar-icon Icon Icon--search" role="presentation"><img src="data:image/gif;base64,R0lGODlhBwAJAIAAAP///////yH5BAEKAAEALAAAAAAHAAkAAAIHjI+py+1cAAA7"><svg viewBox="0 0 56 72"><use fill="currentcolor" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/i/rw/svg/c25636093d431d0e28be32cd59239cf6/icon#icon-search"></use></svg></span></a></div></div></div><div class=" SignUpBar"><div class="u-containerWithGutter"><div …
Run Code Online (Sandbox Code Playgroud)

html android webview jsoup

0
推荐指数
1
解决办法
4192
查看次数