我的应用程序需要处于纵向模式,因此我在清单中将其设置为:
android:screenOrientation="portrait"
Run Code Online (Sandbox Code Playgroud)
但是我最近刚刚添加了另一个片段(FragA),它在外观上看起来和功能都要好10倍.有什么东西可以放在我的FragA中,只是在横向制作该片段,同时保留应用程序的其余部分,或者通过这样做,我必须在我的其他片段中添加一些内容以保留它们作为肖像吗?
我正在自定义ListView中加载手机通讯录.每行都是一个可检查的LinearLayout,包含CheckedTextView和另一个TextView.
我正在使用自定义ArrayAdapter提供列表视图.我的问题是我无法在getView()中控制CheckedTextViews.例如,当我尝试以下内容时
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
if(row == null){
row = inflater.inflate(layout, parent, false);
}
CheckedTextView checkedTextView = (CheckedTextView) row.findViewById(R.id.checkedTextView);
checkedTextView.setText("A");
checkedTextView.setChecked(true);
return row;
}
Run Code Online (Sandbox Code Playgroud)
每当我滚动列表视图时,应该检查每个文本视图,但这不会发生.谁能告诉我怎么做?
编辑:在getView()中检查它是很重要的,我不能在setListAdapter()之后检查所有内容
EDIT2:这是显示每行视图的xml文件
<?xml version="1.0" encoding="utf-8"?>
<com.example.multiplecontacts.CheckableLinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<CheckedTextView
android:id="@+id/checkedTextView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
android:paddingBottom="0dp"
android:text="CheckedTextView"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/subTextView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Small Text"
android:paddingTop="0dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
</com.example.multiplecontacts.CheckableLinearLayout>
Run Code Online (Sandbox Code Playgroud)
CheckableLinearLayout是一个自定义布局,它扩展了LinearLayout并实现了Checkable,如前所述.我从这里拿走了它
对于每个APP的统计网络流量,我现在使用的是Android TrafficStats
我可以获得如下结果:
据我所知,"Android Trafficstats"只是一个指向ac文件的本机指针.(也许是.so?)
但它混合了Wifi和3g流量,有没有办法只获得非WiFi流量统计?
我的应用程序试图计算通过WiFi/LAN和移动数据连接发送和接收的字节数.为此,我TrafficStats在一个时间点获取计数器的值,并在下次检查时从其值中减去该值.
// get current values of counters
long currentMobileTxBytes = TrafficStats.getMobileTxBytes();
long currentMobileRxBytes = TrafficStats.getMobileRxBytes();
long totalTxBytes = TrafficStats.getTotalTxBytes();
long totalRxBytes = TrafficStats.getTotalRxBytes();
// to get mobile data count, subtract old from current
long currentMobileSent = currentMobileTxBytes - oldMobileTxBytes;
long currentMobileReceived = currentMobileRxBytes - oldMobileRxBytes;
// to get WiFi/LAN data count, subtract total from mobile
long currentNetworkSent = totalTxBytes - currentMobileTxBytes;
long currentNetworkReceived = totalRxBytes - currentMobileRxBytes;
Run Code Online (Sandbox Code Playgroud)
我觉得上面的算法是合理的,但是,我不知道如何检查这些计数器的准确性.例如,当我尝试通过WiFi将2.7MB文件上传到Dropbox时,currentMobileSent我得到的值大约是10MB.即使没有浏览网页直到下一次检查,我得到非零值,表明我在等待期间确实收到了一些字节的数据.
有没有办法让我检查TrafficStats这些数字是如何到达的?我知道除了我的浏览器,可能还有其他应用程序在后台运行连接到互联网,但2.7MB到10MB似乎是一个巨大的跳跃 - 我甚至"没有做任何事情"一次"收到"90MB.或者我计算发送和接收的字节的方式有问题吗?
我想知道为什么每次运行任何应用程序时都会显示以下消息.
12-11 17:18:37.141: D/dalvikvm(3155): GC_CONCURRENT freed 485K, 9% free 6696K/7303K, paused 9ms+335ms
paused 9ms+335ms由于这个暂停,我应该播放的音频丢失了,因为根据我的代码,它每次接收音频数据,40ms所以这里它暂停,9ms+335ms因为10 times数据丢失
我知道它执行某种垃圾收集但我的问题是为什么它经常出现在logcat中.
谢谢你的帮助!!!!!!
android garbage-collection memory-leaks memory-management android-logcat
我已经安装了SIPDROID.我在sip2sip做了三个帐户.之后,我使用该帐户之一配置了应用程序.应用程序正常.
问题是:如果我使用SIP多次拨打同一部电话,无论如何都要同时处理所有电话?
第一次通话继续时,另一个来电不会显示在手机屏幕上.
第一个电话被接听,但第一次通话时的第二个电话怎么样.
即使是第二个电话也没有显示在屏幕上.困惑!!
我有
目标android-4
在project.properties中.在eclipse中,当我运行项目时,我收到了错误
没有找到兼容的目标
如何解决这个问题>
我正在研究HttpClientPOST方法.我需要创建HttpClient一次,并且应该使用Keep Alive Connection.但我想在我的情况下,它每次都建立一个新的连接.
所以,我需要使用Keep Alive连接HttpClient.
这是我的代码片段任何帮助将不胜感激.
ClientConnectionManager mgr = httpclient_recv.getConnectionManager();
hp = httpclient_recv.getParams();
httpclient_recv = new DefaultHttpClient(
new ThreadSafeClientConnManager(hp,mgr.getSchemeRegistry()), hp);
while (true) {
try {
java.util.logging.Logger.getLogger("org.apache.http.wire")
.setLevel(java.util.logging.Level.FINER);
java.util.logging.Logger.getLogger("org.apache.http.headers")
.setLevel(java.util.logging.Level.FINER);
System.setProperty("org.apache.commons.logging.Log",
"org.apache.commons.logging.impl.SimpleLog");
System.setProperty(
"org.apache.commons.logging.simplelog.showdatetime",
"true");
System.setProperty(
"org.apache.commons.logging.simplelog.log.httpclient.wire",
"debug");
System.setProperty(
"org.apache.commons.logging.simplelog.log.org.apache.http",
"debug");
System.setProperty(
"org.apache.commons.logging.simplelog.log.org.apache.http.headers",
"debug");
ByteArrayEntity bae = new ByteArrayEntity(byteData);
bae.setContentType(new BasicHeader(HTTP.CONTENT_TYPE,
"binary/octet-stream"));
httppost_recv.setHeader(HTTP.CONN_DIRECTIVE,HTTP.CONN_KEEP_ALIVE);
httppost_recv.setEntity(bae);
{
System.out.println("res b4 response");
response_recv = httpclient_recv
.execute(httppost_recv);
response_recv.getEntity().consumeContent();
System.out.println("res a4 response");
if (response_recv != null) {
byteArray = …Run Code Online (Sandbox Code Playgroud) 从SDK 14开始,首选顺序是取消/确定,而不是之前的确定/取消.我不打算参加关于这是不是一个好主意的辩论,这不是我的问题的主题.
问题是,ADK鼓励您使用SDK> = 14的设备使用新订单,为您提供以下Lint
布局使用错误的按钮顺序API> = 14:创建一个相反顺序的layout-v14/layout.xml文件:取消按钮应位于左侧("@ string/send | Cancel",应为"Cancel | @"字符串/发送")
好的,我会坚持,这对我来说不是问题,我理解我应该遵循建议,以避免烦扰用户.
但事情就是这样......在我的三星Galaxy S II上,在ICS上运行,系统界面本身似乎不遵循新订单.以下是一些屏幕截图示例:

订单是旧订单.请注意,我使用的是我手机的官方ICS版本(不是自定义ROM).我的Galaxy Tab 2(也运行官方ICS)的顺序是一样的.在某些对话框中,订单是正确的(取消/确定)我看到的唯一区别是主题(使用Holo主题的对话框有新订单;其他,旧订单).以下是使用Holo从设置(设置系统日期)和我的应用程序中的DatePickerDialog的屏幕截图:

这非常令人不安.看起来按钮的顺序与主题相关,而不是版本相关.或者只是三星不遵循Android的设计模式?
我认为活动(当他们有确定/取消按钮时)也应遵循相同的顺序.而且,在我的手机上,日历的"创建事件"活动的顺序错误(并且活动不使用"孔"主题):

无论如何,我将在我的应用程序中使用Holo主题设备来自Honeycomb,因此我将保留SDK> = 14的新订单.我只是想了解这个问题.
谢谢.
我正在做一个简单的android应用程序.我正在使用以下代码从数组中删除一个元素.
arr_fav = {"1","2","3"};
for(int i= 0;i<arr_fav.length;i++)
{
if(current_id == Integer.parseInt(arr_fav[i]))
{
arr_fav[1] = null;
} }
Run Code Online (Sandbox Code Playgroud)
通过这样做我得到像arr_fav = {"1",null,"3"}的数组.但我想要像arr_fav = {"1","3"}.如何删除元素.这个Android开发的新手请帮我解决这个问题.
android ×10
java ×3
traffic ×2
3g ×1
arrays ×1
eclipse ×1
http ×1
http-post ×1
httpclient ×1
memory-leaks ×1
orientation ×1
sip ×1
sipdroid ×1
string ×1
voip ×1