小编Fal*_*65o的帖子

以编程方式更改R.String的值

你能在android程序中以编程方式更改R.string的值吗?我需要提取一些API信息(例如电池状态,电池百分比,android os版本),并希望将其保存为R.string值.我知道怎么读它:

 String helloValue= getResources().getString(R.string.hello);
Run Code Online (Sandbox Code Playgroud)

我也看过:以编程方式更改R.string的值?但似乎只涉及改变语言,他最终以不同的方式做到了.有人可以伸出援助之手吗?我也看过这里:http://developer.android.com/guide/topics/resources/string-resource.html并找不到任何帮助:(

android android-2.3-gingerbread

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

在Android上使用DU

是否有类似于我可以在adb shell上使用的unix命令?我正试图找到一种方法来查看每个文件有多大,因为我的应用程序正在变得非常大且失控,我正在尝试确定它是哪个文件/数据库,所以我可以解决这个问题.

我正在Evo 4G上测试这个并得到:

du: permission denied
Run Code Online (Sandbox Code Playgroud)

或者我根/重新安装后:

du: not found
Run Code Online (Sandbox Code Playgroud)

cd进入其他文件夹在任何时候都没有帮助我.

android adb android-sdk-2.3

5
推荐指数
1
解决办法
6661
查看次数

将参数传递给委托 c#

我有一个问题,我希望向委托添加函数调用,但每个函数调用都有一个唯一的参数。我无法弄清楚或在其他地方找到解决方案,所以我转向你们:)

下面一些伪..

(所以基本上,我正在创建一个委托和一个事件,并且 AddToDelegate 函数应该将函数调用添加到事件(具有唯一值),然后 GetData 函数返回一个字符串中的所有响应 -问题出在AddToDelegate 函数作为该行a += new A(SomeFunc)(i.ToString());实际上应该只是一个+= new A(SomeFunc);)

有没有办法与代表一起做到这一点 - 或者我是否在错误的树上咆哮?

public delegate string A(string s);
public event A a;

public void AddToDelegate()
{
    for (int i = 0; i < DelegateList.Length; i++)
    {
        a += new A(SomeFunc)(i.ToString());
    }
}

public string GetData()
{
    StringBuilder _sb = new StringBuilder();
    if (a != null)
    {
        Delegate[] DelegateList = a.GetInvocationList();
        for (int i = 0; i < DelegateList.Length; i++)
        {
            _sb.Append(((A)DelegateList[i])); …
Run Code Online (Sandbox Code Playgroud)

c# delegates

5
推荐指数
1
解决办法
7775
查看次数

我什么时候应该使用头文件?

在为当地一所大学的几名学生辅导之后,我被问到"与普通的.cpp文件相比,何时最好使用C++中的头文件?".我有点挣扎着答案,并且看看是否有一个更明确的答案,在哪些场景下最好的.

使用可在多个项目中使用的代码时最好使用头文件吗?我知道这是一个愚蠢的例子,但如果你做了自定义数学函数,可以在其他项目中反复使用; 那最好放在头文件中是否正确?

c++ oop

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

位于Dialog中的EditText上的NullPointerException

这是我的email_dialog.xml布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

<TableRow
    android:id="@+id/tableRow0"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >
</TableRow>

<TableRow
    android:id="@+id/tableRow1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <EditText
        android:id="@+id/txtEmailAddress5"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="textEmailAddress" 
        android:text="mFry@smithmicro.com"/>

</TableRow>

   <TableRow
    android:id="@+id/tableRow2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

       <Button
           android:id="@+id/btnCancelEmail"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:width="200px"
           android:text="Cancel" />

       <Button
           android:id="@+id/btnOkEmail"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:width="200px"
           android:text="Email" />

</TableRow>
Run Code Online (Sandbox Code Playgroud)

这是我调用和使用它的方法:

void showEmailDialog() {
    // Final prevents the error in the newest onClick callback.
    final Dialog dialog = new Dialog(this);

    dialog.setContentView(R.layout.email_dialog);
    dialog.setTitle("Enter Email Address");
    dialog.setCancelable(true);

    final EditText txtEA = (EditText) findViewById(R.id.txtEmailAddress5);
    final Button …
Run Code Online (Sandbox Code Playgroud)

android nullpointerexception android-layout

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