我正在尝试创建一个AppWidget,其中TextView的背景颜色以指定的周期间隔随机变化.
TextView在布局xml文件中定义为
<?xml version="1.0" encoding="utf-8" ?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/message"
android:background="#ff99ff"
android:text="Hello Widget" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
在更新方法中,我已将布局加载为
RemoteViews remoteView=new RemoteViews(context.getPackageName(),R.layout.widget_message);
Run Code Online (Sandbox Code Playgroud)
要更改TextView的背景,我使用以下语句
remoteView.setInt(R.id.message, "setBackgroundResource", R.color.col_1);
Run Code Online (Sandbox Code Playgroud)
但我得到一个小部件说问题加载小部件.如果我删除上面的行一切正常.
LogCat说:
updateAppWidget使用错误视图找不到任何视图
android.widget.RemoteViews $ ActionException:view:android.widget.TextView无法使用RemoteViews方法:setBackgroundResource(int)
我只是尝试使用表格布局来显示一些数据....数据是一个3列数据,我希望列应该利用可用的整个宽度.但似乎我使用的布局XML代码只是根据内容包装列.
布局XML代码
<?xml version="1.0" encoding="utf-8"?>
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TableRow
android:layout_width="fill_parent">
<TextView
android:padding="3dip"
android:gravity="left"
android:text="Name"
/>
<TextView
android:padding="3dip"
android:gravity="left"
android:text="Address"
/>
<TextView
android:padding="3dip"
android:gravity="left"
android:text="Age"
/>
</TableRow>
</TableLayout>
Run Code Online (Sandbox Code Playgroud) 在我的系统上,我正在安装Android SDK和ADT插件时使用eclipse ganymede版本.我创建了一个512MB内存的Android AVD(目标android 1.5).看到它的缓慢启动令人非常沮丧.完成启动大约需要4-5分钟.是否有任何方法或调整来加快此启动过程.
PC配置:
P4 2.4 Ghz,1 GB内存.
UILongPressGesture可在ios ver 3.2及更高版本中使用.但我正在尝试开发应用程序以实现最大兼容性,从而针对ios ver2.0
任何人都可以指导我如何在ios v2.0中完成长按手势
我有一个文件,其中有许多行我必须删除。这些行可以使用正则表达式来区分,因此利用一系列搜索和替换我可以删除它们。
现在我必须多次重复同样的任务。所以我正在寻找一种方法,我不需要一次又一次地经历这一系列的替换。有没有办法将这一系列替换批处理/脚本化为单个命令。
我尝试通过录制宏来做到这一点,但似乎不起作用。
我有一个在XML文件中定义的表,当前设置为垂直滚动.但我也希望它根据需要水平滚动.
这是使用中的XML代码
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:scrollbars="vertical"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="0,1,2"
android:id="@+id/tLayout"
android:scrollbars="vertical"
>
<TableRow
android:layout_width="fill_parent">
<TextView
android:padding="3dip"
android:gravity="left"
android:text="Name"
/>
<TextView
android:padding="3dip"
android:gravity="left"
android:text="Address"
/>
<TextView
android:padding="3dip"
android:gravity="left"
android:text="Age"
/>
</TableRow>
</TableLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud) 我有一个表格布局,其中定义了3列.但是由于第二列中的大文本,内容将离开屏幕.所以我试图放置一个水平滚动条.但是无法做到.
我使用Android 1.5作为目标.
表格布局的XML代码
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:scrollbars="horizontal"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:stretchColumns="0,1,2"
android:id="@+id/tLayout"
android:scrollbars="horizontal"
>
<TableRow
android:layout_width="fill_parent">
<TextView
android:padding="3dip"
android:gravity="left"
android:text="Name"
/>
<TextView
android:padding="3dip"
android:gravity="left"
android:text="Address"
/>
<TextView
android:padding="3dip"
android:gravity="left"
android:text="Age"
/>
</TableRow>
</TableLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud) 我正在尝试这种表格布局,其中有三列,每列尽可能利用最大空间(使用strechColumn标签).现在,当列获取的内容太长时,表格布局会跳出屏幕.
如何设置要包装的列的内容,以便表格布局不会跳出屏幕.
这是我使用的表格布局的XML代码
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:scrollbars="vertical"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="0,1,2"
android:id="@+id/tLayout"
android:scrollbars="vertical"
>
<TableRow
android:layout_width="fill_parent">
<TextView
android:padding="3dip"
android:gravity="left"
android:text="Name"
/>
<TextView
android:padding="3dip"
android:gravity="left"
android:text="Address"
/>
<TextView
android:padding="3dip"
android:gravity="left"
android:text="Age"
/>
</TableRow>
</TableLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)