所以我有一个自定义的ListView对象.列表项目有两个堆叠在一起的文本视图,加上一个水平进度条,我想保持隐藏,直到我实际执行某些操作.最右边是一个复选框,我只想在用户需要将更新下载到他们的数据库时显示.当我通过将可见性设置为Visibility.GONE来禁用复选框时,我可以单击列表项.当复选框可见时,除了复选框之外,我无法单击列表中的任何内容.我做了一些搜索,但没有找到任何与我目前的情况相关的东西.我发现了这个问题,但我使用的是重写的ArrayAdapter,因为我正在使用ArrayLists在内部包含数据库列表.我只需要获取LinearLayout视图并像Tom一样添加onClickListener吗?我不确定.
这是listview行布局XML:
<?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="?android:attr/listPreferredItemHeight"
android:padding="6dip">
<LinearLayout
android:orientation="vertical"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="fill_parent">
<TextView
android:id="@+id/UpdateNameText"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:layout_weight="1"
android:textSize="18sp"
android:gravity="center_vertical"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:id="@+id/UpdateStatusText"
android:singleLine="true"
android:ellipsize="marquee"
/>
<ProgressBar android:id="@+id/UpdateProgress"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:indeterminateOnly="false"
android:progressDrawable="@android:drawable/progress_horizontal"
android:indeterminateDrawable="@android:drawable/progress_indeterminate_horizontal"
android:minHeight="10dip"
android:maxHeight="10dip"
/>
</LinearLayout>
<CheckBox android:text=""
android:id="@+id/UpdateCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
这是扩展ListActivity的类.显然它仍在开发中,所以请原谅那些遗漏或可能留下的东西:
public class UpdateActivity extends ListActivity {
AccountManager lookupDb;
boolean allSelected;
UpdateListAdapter list;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
lookupDb = new AccountManager(this);
lookupDb.loadUpdates();
setContentView(R.layout.update);
allSelected = false; …
Run Code Online (Sandbox Code Playgroud) 我知道以下代码应该在Android中显示并隐藏一个带有以下代码的小型循环进度条:
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setProgressBarIndeterminateVisibility(true);
setProgressBarIndeterminateVisibility(false);
Run Code Online (Sandbox Code Playgroud)
问题是我正在使用TabHost,我需要能够从一个"子"活动中做到这一点.我有什么办法可以做到这一点吗?
我在intarwebs上发现了这个问题,但正如你所看到的,它没有得到答复.
这是交易.我有一个带有三个标签的应用程序.通过与选项卡中的项目的各种交互,我最终启动了其他活动.客户审查这一点,并希望推出的"内"选项卡中的活动,这样的标签仍然可见,如果用户点击标签它可以追溯到在setContent函数中定义的原始活动.这是可能的,我将如何从其他活动中解决这个问题?(即子活动,而不是定义TabHost并有权调用setContent的那个)?
我们正在为SQLite数据库中具有数百兆字节HTML的客户端创建一个应用程序.我们已经实现了一种查询此数据的方法,并以合理快速的方式滚动浏览所有数据.问题是某些数据库有非常大的查询(20,000多行),当我们在用户滚动时增加查询时,我们会看到错误.所以我想问题是,我们在Android中查询和显示数万行数据时有哪些选择?
这是我们看到的堆栈跟踪:
09-10 19:19:12.575: WARN/IInputConnectionWrapper(640): showStatusIcon on inactive InputConnection
09-10 19:19:18.226: DEBUG/dalvikvm(640): GC freed 446 objects / 16784 bytes in 330ms
09-10 19:19:32.886: ERROR/CursorWindow(19416): need to grow: mSize = 1048576, size = 36, freeSpace() = 30, numRows = 17717
09-10 19:19:32.896: ERROR/CursorWindow(19416): not growing since there are already 17717 row(s), max size 1048576
09-10 19:19:32.916: ERROR/CursorWindow(19416): The row failed, so back out the new row accounting from allocRowSlot 17716
09-10 19:19:33.005: ERROR/Cursor(19416): Failed allocating fieldDir at startPos 0 row 17716 …
Run Code Online (Sandbox Code Playgroud) 我正在为此应用程序编写内容提供程序,在我的内容提供程序中,我打开数据库连接,运行查询并将结果的光标返回给调用程序.如果我在提供程序中关闭此数据库连接,则游标没有结果.如果我打开它,我的DDMS日志中会出现"泄漏发现"错误.我在这里错过了什么?什么是返回数据库结果光标的干净,正确的方法?
好吧,所以这是交易.我有两个表和一个连接表,因为它是一个多对多的关系.我有订单,订单可以有很多产品.显然,它是另一种方式,因为产品可以在许多订单上.我有以下课程:
class Order < ActiveRecord::Base
has_many :orders_products
has_many :products, :through => :orders_products
end
class OrderProduct < ActiveRecord::Base
belongs_to :order
belongs_to :product
end
class Product < ActiveRecord::Base
has_many :orders_products
has_many :orders, :through => :orders_products
end
Run Code Online (Sandbox Code Playgroud)
我正在显示一个页面,我可以输入内容,当我通过保存的订单与产品进行交互时,@order.products
我收到以下错误:
SQLite3::SQLException: no such table: order_products: SELECT "products".* FROM "products" INNER JOIN "order_products" ON "products".id = "order_products".product_id WHERE (("order_products".order_id = 1))
Run Code Online (Sandbox Code Playgroud)
我的连接表已命名orders_products
,但您可以看到它正在尝试加入order_products
.我对Rails命名约定的有限知识告诉我,这orders_products
是命名它的正确方法,然后将我的模型命名为OrderProduct
.我真的在这个墙上碰到了一堵墙.
编辑:我看到即使它保存了我的订单它我选择了多个复选框它没有保存orders_products
表中的任何值,大概是因为它现在错误的原因相同.
我真的把头发拉过来.一些背景.我有一个项目列表,旁边都有复选框.取消选中复选框后,会出现一个按钮,允许您从列表中删除该项目.这看起来似乎倒退,但我们只希望"选定"的项目有资格进行进一步处理,等等.这是我的布局:
<RelativeLayout android:id="@+id/rlBlahBlah"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
xmlns:android="http://schemas.android.com/apk/res/android">
<CheckBox android:text=""
android:id="@+id/cbDeleteItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:focusable="false"
/>
<TextView android:text=""
android:id="@+id/tvItemText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14dip"
android:paddingLeft="3dip"
android:paddingRight="3dip"
android:paddingTop="13dip"
android:gravity="fill_vertical"
android:layout_toRightOf="@id/cbDeleteItem"
/>
<Button android:layout_height="wrap_content"
android:id="@+id/btnDelete"
android:text="Delete"
android:layout_width="wrap_content"
android:layout_alignParentRight="true"
android:gravity="center_vertical"
android:focusable="false"
/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
为了挽救我的生命,我不能让3个项目垂直居中.layout_gravity
,gravity
,layout_centerVertical
,没有它的工作原理.我敢肯定我的问题是在某个地方翻转的一个小小的设置,但我真的在这个问题上结束了.
编辑:我知道textview是"fill_vertical",这是我尝试的一些随机的东西.
https://myapp.com -> https://abcdefgh34545.cloudfront.com -> https://myBucket.s3-eu-west-1.amazonaws.com/index.html
我如何使用Prerender.io
此堆栈的服务?我必须以某种方式检测WebSpider/WebRobot正在访问该页面并将其重定向到prerender.io ...
我希望能够启动一个活动或服务并尽快获得该过程的PID,这将是最好的情况.除了浏览/ proc目录之外,我还有其他任何选项吗?这会导致活动/服务启动时间与我在proc中找到我想要的内容之间的可变时间竞争条件目录并开始观察?
这是交易:我有一个Android应用程序需要每X秒(当前60秒)调用一个Web服务.此应用程序有多个选项卡,这些选项卡都需要与数据本身进行交互.一个是MapView,一个是ListView,然后第三个是无关紧要的,但最终还需要得到一些全局数据.问题是我希望我的主要活动有一个在后台运行的线程,获取结果,然后指示TabHost中的两个子活动使用最新数据更新自己.此外,当用户单击选项卡并触发onCreate/onResume活动时,我还想通过从主活动获取最新数据来强制重绘.我真的很茫然.我已尝试使用服务和一些ghetto静态方法将活动的实例传递给服务,以便在定时器触发时调用特定函数来更新其视图,但减速非常糟糕且代码只是丑陋难看丑陋.有什么建议?
编辑:所以我在tabhost活动中将其实现为计时器驱动的线程,然后我在每个子活动中都有计时器驱动的线程,然后获取数据(以同步的方式)并更新它们的地图/列表.它的速度要快得多,但仍然感觉有点破解,尤其是我在父活动中调用自定义函数的部分,如下所示:
((MainActivity)getParent()).getNearbyMatches();
Run Code Online (Sandbox Code Playgroud)
这增加了一个强烈耦合的元素,我并不十分兴奋,但从性能的角度来看,它比它更好.我很欣赏已经给出的答案,并将对内容提供商进行一些研究,但我不确定是否要回到服务模型.