我创建了一个特定的List,它存在于以下元素之外,用于创建一个可滚动的列表,每行包含左侧的Image和右侧的一些文本:
首先是"根"布局:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#C8C8C8"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:drawSelectorOnTop="false"
android:divider="#C8C8C8"
android:background="#C8C8C8"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
然后在ListView中我放置以下"行"项:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@drawable/bg_row"
>
<ImageView
android:layout_width="wrap_content"
android:paddingLeft="10px"
android:paddingRight="15px"
android:paddingTop="5px"
android:paddingBottom="5px"
android:layout_height="wrap_content"
android:src="@drawable/bg_image"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="5px"
android:paddingBottom="5px"
android:textSize="16sp"
android:textColor="#000000"
android:layout_gravity="center"
android:maxHeight="50px"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
只要屏幕静态显示(没有移动)就会正确显示,但是当我开始滚动列表时,行项目的背景(代码中显示的"图标")将是正确显示,但"根"布局的背景将变成完全黑色...当滚动停止时,背景将会,大多数时候,恢复它的颜色...当我测试时我也在TextView该根元素中添加了一个具有相同的背景,当滚动列表时,这个将保留它的颜色...任何想法为什么会发生这种情况,以及如何解决这个问题?
我一直在Android开发者网站上阅读以下文本,特别是在框架主题 - >服务 - >启动服务下.
在那里它陈述如下:
如果服务不提供绑定,则使用startService()提供的意图是应用程序组件与服务之间唯一的通信方式.但是,如果您希望服务返回结果,则启动服务的客户端可以为广播创建PendingIntent(使用getBroadcast())并将其传递给启动服务的Intent中的服务.然后,该服务可以使用广播来传递结果.
我有几个问题:
Services 和 IntentService s?Service; 然后,该服务可以使用广播来传递结果.以及所提到的广播将结果传递给原始客户/活动的位置?是否有一些方法应该被覆盖(比如onActivityResult())或什么?我想知道是否可能(以及如何)在特定时间启动我的应用程序,就像闹钟在特定时间熄灭.假设我希望我的应用程序在早上8点启动,这是可行的吗?
我已经看到了几个如何实现BroadCastReceiver的例子,但是我应该如何实现一个必须对一些待处理的Intent做出反应的服务(例如来电)...实际上我想知道同样的"问题"但是在活动..你显然有一个扩展服务或活动的类)所以它也不能扩展BroadCastReceiver ...看起来我们不能制作"平台感知"服务和/或活动?
我是Python的新手,我试图将单词中的所有大写字母替换为下划线,例如:
ThisIsAGoodExample
Run Code Online (Sandbox Code Playgroud)
应该成为
this_is_a_good_example
Run Code Online (Sandbox Code Playgroud)
关于如何实现这一目标的任何想法/提示/链接/教程?
我有一个XML布局,其中包含一个TableLayout,其中包含一个未知数量的TableRows ...行数将在运行时建立,但我知道的是我想要两列...所以我有几个问题这个 :
- 有没有一种方法可以为(在运行时)创建的TableRows提供一个id,它将放在TableLayout中,所以我可以稍后从软件的其他部分引用它们?
我有以下表示ImageButton的xml对象
<?xml version="1.0" encoding="utf-8"?>
<ImageButton
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/genreCellItemId" android:layout_weight="1"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center"
android:paddingLeft="5.0dip" android:paddingRight="5.0dip">
</ImageButton>
Run Code Online (Sandbox Code Playgroud)
我尝试对它进行充气并使用以下代码将其添加到TableRow:
LayoutInflater inflater= this.getLayoutInflater();
TableLayout grid = (TableLayout)findViewById(R.id.bodyTableLayout);
TableRow row = (TableRow)inflater.inflate(R.layout.genre_row, null);
View myButton = (View)inflater.inflate(R.layout.genre_cell, null);
row.addView(tempButton, new TableRow.LayoutParams());
grid.addView(row, new TableLayout.LayoutParams());
Run Code Online (Sandbox Code Playgroud)
好的,所以我注意到它没有预期的那样,所以我启动Hierarchy Viewere并注意到ImageButton实际上有一个layout_width = FILL_PARENT而不是WRAP_CONTENT,而且layout_gravity也是NONE,并且没有看到填充. .
我做错了吗?或者是新的TableRow.LayoutParams()部分可能是错误的吗?
我正在Android上开发,但问题可能在任何其他Java平台上都同样有效.
我开发了一个多线程应用程序.假设我有一个需要执行时间密集型任务的第一类,因此这项工作在另一个Thread中完成.完成后,相同的Thread会将时间密集型任务结果返回给另一个(第3个)类.
最后一个类将执行某些操作并将其结果返回到第一个启动类.我注意到虽然第一堂课将一直等待,也许是因为这是某种循环?
另外我想让Thread-class停止运行,就像它将结果传递给第三类时它应该停止一样.第三类必须在没有被"封装"在第二类(线程一)的情况下完成它的工作.谁知道怎么做到这一点?
现在的经验是,第一个似乎在等待(悬挂)直到第二个和第三个完成:(