小编use*_*224的帖子

如何在Android中阅读文本文件?

我想从文本文件中读取文本.在下面的代码中,发生异常(这意味着它进入catch块).我把文本文件放在应用程序文件夹中.我应该把这个文本文件(mani.txt)放在哪里才能正确读取它?

    try
    {
        InputStream instream = openFileInput("E:\\test\\src\\com\\test\\mani.txt"); 
        if (instream != null)
        {
            InputStreamReader inputreader = new InputStreamReader(instream); 
            BufferedReader buffreader = new BufferedReader(inputreader); 
            String line,line1 = "";
            try
            {
                while ((line = buffreader.readLine()) != null)
                    line1+=line;
            }catch (Exception e) 
            {
                e.printStackTrace();
            }
         }
    }
    catch (Exception e) 
    {
        String error="";
        error=e.getMessage();
    }
Run Code Online (Sandbox Code Playgroud)

java android exception-handling inputstream

107
推荐指数
5
解决办法
30万
查看次数

通过编码的textview边框

我有一个TextView通过java编码创建,我需要通过编码绘制边框.请参考下面的代码,

TextView txt = new TextView(this);
txt.setText("SEARCH TABLE");
txt.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
txt.setFadingEdgeLength(10);
txt.setTextColor(Color.WHITE);
txt.setBackgroundColor(Color.rgb(83,82,82));
txt.setPadding(10, 5, 10, 0);
txt.setGravity(Gravity.CENTER);
txt.setTypeface(Typeface.SERIF,Typeface.BOLD);
Run Code Online (Sandbox Code Playgroud)

怎么做 ?

android

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

单击静态文本的事件

我有一个名为IDC_STATIC的静态文本,我为其创建了一个click事件,但是当它被单击时它没有被调用.

ON_BN_CLICKED(IDC_STATIC, ontest)  //(begin message map)
void test::ontest(my method)
{
  MessageBox("success");
}
afx_msg void test();  //(header file)
Run Code Online (Sandbox Code Playgroud)

代码有什么问题?

mfc visual-c++

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