DeskAngel

Desktop softwares and information

Follow me on TwitterRSS Feeds

  • Home
  • DeskAngel
  • Oolauncher
  • Wsizer

滚动到TextView底部

Apr 22nd

Posted by WilliamX in Programming

No comments

在Android,一个单独的TextView是无法滚动的,需要放在一个ScrollView中。ScrollView提供了一系列的函数,其中fullScroll用来实现home和end键的功能,也就是滚动到顶部和底部。

但是,如果在TextView的append后面马上调用fullScroll,会发现无法滚动到真正的底部,这是因为Android下很多(如果不是全部的话)函数都是基于消息的,用消息队列来保证同步,所以函数调用多数是异步操作的。当TextView调用了append会,并不等text显示出来,而是把text的添加到消息队列之后立刻返回,fullScroll被调用的时候,text可能还没有显示,自然无法滚动到正确的位置。

解决的方法其实也很简单,使用post:

final ScrollView svResult = (ScrollView) findViewById(R.id.svResult);
svResult.post(new Runnable() {
    	public void run() {
    	    svResult.fullScroll(ScrollView.FOCUS_DOWN);
    	}
});
android, tips

Formulas for DaCalc

Apr 20th

Posted by WilliamX in Information

No comments

How to use the following formulas:

  1. In DaCalc, composing window, write the expression (red part) to the edit box and save with the name of the formula (black bold part).
  2. Copy every expression (red part) to a file and saved the file with the name of the formula (black bold part) to /sdcard/DaCalc. Open DaCal, in Load window, click Import in the menu.

Minimal request DaCalc version: 1.2.0.0

  1. Monthly mortgage:
    monthly mortgage=principal*rate*(1+rate)^month/((1+rate)^month-1)
  2. Best sell price for a stock:
    sell price=profit/shares + badeprice * (1+rate)/(1-rate-tax)
  3. Body mass index:
    bmi=weight / (height / 100) ^ 2
android, DaCalc
Main Window

How to use DaCalc

Apr 16th

Posted by WilliamX in Software

No comments

DaCalc is an formula calculator running on Android mobile system. It can be used to calculate like tips, tax and so on. In the following session, I will show you how to use DaCalc to calculate tips in your Android mobile phone, like Hero.

Main Window

Figure 1 Main Window

Session 1, use the pre-defined function:

  1. After started, main window of DaCalc looks like figure 1.
  2. Click the menu button on your phone, an option menu will pop-up.
  3. Click the “Load” menu item, it will switch to the “expression load” window. There is a default expression name tips.
  4. Short click the function “tips“, DaCalc will switch to the main window after the function loaded. The expression for “tips” is “cost * 0.2“. Variable “cost” is added to the spinner.
  5. Input value for the variable “cost“, then click “=” on the panel to calculate the result.

Session 2, define your own function:

  1. Click the menu button on your phone when the main window is displaying.
  2. Click the “Edit” menu item, it will switch to the “composing” window.
  3. In put cost * 0.2 / person.
  4. Click the “Save” button. If you input an invalid expression, there will pop-up a text message. But the verifier is very week, so you should ensure that your input is a correct expression.
  5. If the expression is correct, a dialog will pop-up. You must input a name for the function/expression, like “tips-per“.
  6. Click “Okay“, the function will be saved to database. You can click “Load” button to check.
  7. Click “Back” button to switch to the main window.
  8. Now, click the “Load” menu item and click on the “tips-per” function to load.
  9. Input a value for the variable “cost“, then press “=“, the spinner will swith to the next variable “person“.
  10. Input a value for the variable “person” to calculate the result.

If you encounter any problem when using DaCalc, please do not hasitate to send me a email, with your expressions.

android, DaCalc, formula, tips

/etc/init.d/*

Apr 9th

Posted by WilliamX in Software

No comments

今天因为刷Villain 5.2遇到点问题,apps2sd开启后无法启动,原因是/system/sd无法自动挂载,所以研究了一下。最后发现这个rom中,busybox的命令被映射到了/system/xbin/bb下面,但是该路径不在$PATH中,导致很多命令找不到,/etc/init.d/*下的脚本无法正确执行。

一开始以为只要在一个文件中添加

export PATH=$PATH:/system/xbin/bb

就可以了,但是实际上每个文件都是在独立的shell中运行,需要逐个添加。

最后,把修改好的文件传到/system/etc/init.d/下后,还需要运行

chmod 0755 /system/etc/init.d/*

我忘了这一步,结果浪费了一些时间。

android

EditText在ListView中内容被清空的问题

Mar 31st

Posted by WilliamX in Programming

No comments

遇到这个问题是在设计一个Android程序的Ui的时候,当把EditText放在ListView中之后,就遇到了两个问题:

  1. 点击EditText,虽然弹出了软键盘,但是没有立刻获得输入焦点
  2. 输入完成之后,按回车或是返回键退出软键盘的时候,EditText框中的输入会被清空

Google无果之后,只有自己研究,谁知这两个问题就花了我几个小时的测试。测试了Android v1.5~v2.1之后,发现原来这两个问题都和ListView的一个参数有关系,即只要没有把ListView的android:layout_height设置成“fill_parent”,就万事大吉。

这个限制没有丝毫道理,应该是ListView的一个讨厌的bug。

但是等一下,ListView是一个scroll container,如果item的个数较多,出现了滚动条,会不会有问题?应该是没有问题,这完全不搭嘎嘛!可惜事实不是这样的。如何避免这个问题,还需要再行研究。

android
«12345»...Last »
  • Tags

    AdjBrightness aero android c++ DaCalc DaysAndDate deskangel eclipse emacs formula gnupgp gpg4win iphone latitude locale mac ntfs object oriented oolauncher openpgp opera photo Prince of Persia printf psi regular expression speedcommander stdout symbol link The Forgotten Sands tips unicode virtual memory vs2010 wii wildcard win7 wine working set wsizer
  • DeskAngel Sites

    • DeskAngel
    • Oolauncher
    • Wsizer
  • Other links

    • wkcow
    • 沧海一粟
  • Calendar

    September 2010
    S M T W T F S
    « Aug    
     1234
    567891011
    12131415161718
    19202122232425
    2627282930  
  • Recent Posts

    • Share DaysAndDate and get Ads removal code
    • error RC1106: invalid option: -ologo
    • 使用wine在Mac上运行Win程序
    • Adjust brightness for Android devices
    • 波斯王子:遗忘之沙(WII)剧情
  • Recent Comments

    • Josh on Adjust brightness for Android devices
    • WilliamX on Adjust brightness for Android devices
    • Josh on Adjust brightness for Android devices
    • Deeznutz1977 on Adjust brightness for Android devices
    • WilliamX on Adjust brightness for Android devices
  • Archives

    • August 2010 (1)
    • July 2010 (3)
    • June 2010 (2)
    • May 2010 (2)
    • April 2010 (6)
    • March 2010 (9)
    • February 2010 (5)
    • January 2010 (1)
    • October 2009 (1)
    • September 2009 (3)
    • July 2009 (1)
    • June 2009 (3)
    • March 2009 (3)
    • February 2009 (7)
  • Categories

    • Critique
    • Information
    • News
    • Programming
    • Software
    • Source
  • Meta

    • Register
    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.org
  • My latest tweets

    Loading tweets...
    Follow me on Twitter!
Mystique theme by digitalnature | Powered by WordPress
RSS Feeds XHTML 1.1 Top