我有一个列表,我为此编写了一个自定义适配器.我想为此设置一些文本颜色(例如橙色代码#F06D2F).我正在为我的getView()
方法提供代码片段.
TextView text = new TextView(this.context);
// text.setPadding(25, 5, 0, 0);
text.setBackgroundResource(R.drawable.back_horizontal);
// text.setClickable(false);
// text.setFocusable(false);
text.setEllipsize(TruncateAt.END);
text.setSingleLine(true);
// text.setTextColor(R.color.yellow);
text.setTextColor(R.color.Orange);
text.setGravity(Gravity.CENTER_VERTICAL);
helvetica_normal = Typeface.createFromAsset(context.getAssets(), "fonts/helvetica.ttf");
text.setTypeface(helvetica_normal);
// text.setTextColor(R.color.yellow);
text.setText(objects[position]);
LayoutParams layoutParams = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
manager.addView(text, layoutParams);
Run Code Online (Sandbox Code Playgroud)
问题是我看不到颜色设置为橙色.什么地方出了错?
注意:上下文在构造函数和对象(字符串数组)中传递
谢谢你的帮助
我打算用Mono和SQLite作为数据库来做一个项目.开发主要在Mac上完成.我已成功设置Mono并测试了System.Data.SQLite(托管dll).简单的测试应用程序完美运
但是,当我尝试DataTable
在我的代码中使用时,它会抛出运行时异常.以下是代码段:
public static void Main (string[] args)
{
string connectionString = "Data Source=emp.db";
try {
using (SQLiteConnection conn = new SQLiteConnection(connectionString))
{
string query = "SELECT firstname, lastname FROM employees";
using (SQLiteCommand comm = new SQLiteCommand(query, conn))
{
conn.Open();
comm.CommandText = query;
using (SQLiteDataReader reader = comm.ExecuteReader())
{
while (reader.Read())
{
string firstname = reader.GetString(0);
string lastname = reader.GetString(1);
Console.WriteLine("Name: " + firstname + " " + lastname);
}
DataTable dt = new DataTable();
dt.Load(reader); // line …
Run Code Online (Sandbox Code Playgroud)