我正在努力解决以下问题:我的应用程序使用HttpClient向http服务器发出一系列请求.我使用HttpPut将数据发送到服务器.第一个请求进行得很快,第二个请求挂起40秒,然后我抓住Connection超时异常.我正在尝试重用我的HttpClient并通过同一个实例发送第二个请求.如果我与新的ConnectionManager一起创建新的HttpClient,那么一切正常.
为什么会这样?以及如何修复它并且每次都不创建新的HttpClient?
提前致谢.
这是我的代码:(如果我在doPut中评论readClient = newHttpClient(readClient),那么问题就出现了.
public class WebTest
{
private HttpClient readClient;
private SchemeRegistry httpreg;
private HttpParams params;
private URI url; //http://my_site.net/data/
protected HttpClient newHttpClient(HttpClient oldClient)
{
if(oldClient != null)
oldClient.getConnectionManager().shutdown();
ClientConnectionManager cm = new SingleClientConnManager(params, httpreg);
return new DefaultHttpClient(cm, params);
}
protected String doPut(String data)
{
//****************************
//Every time we need to send data, we do new connection
//with new ConnectionManager and close old one
readClient = newHttpClient(readClient);
//*****************************
String responseS = null;
HttpPut put = new HttpPut(url); …Run Code Online (Sandbox Code Playgroud) 我有一个内部有两个ImageView的布局.每个图像具有固定的宽高比,例如第一图像是320x160,第二图像是320x320.布局垂直对齐.我希望将这两个图像粘合在一起并缩放以适合屏幕两侧(宽度或高度),并在另一侧进行缩放.我尝试使用scaleType = fitCenter,但问题是在不同宽高比的手机上,图像不在一起,它们之间有黑色区域.似乎我不能使用布局:重量,因为屏幕有不同的比例(480x854和480x800),我需要我的布局保持相同的比例.
任何帮助表示赞赏.
这是我现在的布局:
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ImageView android:src="@drawable/im_menu"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|top"
android:layout_weight="0.7"
>
</ImageView>
<ImageView android:src="@drawable/im_field"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|top"
android:layout_weight="0.3"
>
</ImageView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud) 我需要在列表视图中实现半透明的行选择,并且还需要"按下"状态.
如果我应用纯色,那么一切都按预期工作.但是,如果我应用半透明颜色(#44444444),那么我会看到默认选择颜色(我的2.3 android上的橙色),并且在它上面有我的颜色(它略微变暗橙色).
为什么我的颜色下面有橙色?如何解决这个问题?
这是我的代码:drawable/listselectorinvisible.xml中的Selector xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="false"
android:state_selected="false"
android:drawable="@color/transparent" />
<item android:state_pressed="true"
android:drawable="@color/semitransparent" />
<item android:state_selected="true" android:state_pressed="false"
android:drawable="@color/semitransparent" />
</selector>
Run Code Online (Sandbox Code Playgroud)
Listview行在layout/topscore_row.xml中定义
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:background="@drawable/listselectorinvisible">
<TextView android:layout_height="wrap_content" android:id="@+id/scrowNum" android:textColor="@color/fontButColor" android:text="#" android:textSize="24sp" android:layout_width="32dip" android:gravity="right|top" android:layout_gravity="top"></TextView>
<LinearLayout android:layout_height="wrap_content" android:id="@+id/scrowNamLay" android:layout_width="142dip" android:orientation="vertical">
<TextView android:layout_height="wrap_content" android:paddingTop="2dip" android:layout_width="fill_parent" android:id="@+id/scrowPlayer" android:textColor="@color/fontButColor" android:text="@string/tblPlayer" android:textSize="24sp" android:paddingLeft="2dip"></TextView>
<TextView android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/scrowOpPlayer" android:textColor="@color/fontButColor" android:text="@string/tblPlayer" android:textSize="14sp" android:paddingLeft="2dip"></TextView>
</LinearLayout>
<ImageView android:id="@+id/scrowImg" android:layout_height="wrap_content" android:src="@drawable/small_im_bt" android:padding="2dip" android:layout_marginTop="2dip" android:layout_width="26dip"></ImageView>
<TextView android:layout_height="wrap_content" android:layout_width="48dip" android:id="@+id/scrowScore" android:layout_marginRight="5dip" android:gravity="right" android:textColor="@color/fontButColor" android:text="@string/tblScore" android:textSize="26sp"></TextView>
<TextView android:layout_height="wrap_content" …Run Code Online (Sandbox Code Playgroud) 如何以最小的sw800dp宽度为ICS上的不同dpi分配不同的资源?
详细信息:有两个带有ICS 4.0.4的平板电脑。第一个具有1280x800分辨率和mdpi(160)密度。第二个具有1920x1200分辨率和hdpi(240)密度。因此,就最小宽度而言,它们都具有相同的sw800dp限定符,但具有不同的mdpi / hdpi密度限定符。
对于这两种分辨率,我需要具有不同的布局和图像。
所以我创建了两个目录:
布局-sw800dp-mdpi
布局-sw800dp-hdpi
我认为每个设备都会根据最小的宽度和密度选择自己的目录。但是他们两个都从同一个sw800dp-hdpi文件夹中获取资源!
我很困惑,不知道如何为这两种不同的决议分开资源。
任何帮助都非常感谢。提前致谢。
我在Android市场上发布了免费应用程序,并在第一天看到了安装的进度.但是在第二天等我的安装计数器仍然停止,但主动安装正在增加.
目前我的开发者控制台中有以下内容:
我知道用户数量在增加,但为什么第一个计数器没有呢?
只有第二个增加,但我认为它没有参与公共市场,所以我仍然在100-500范围内:(
我正在开发将视频转换为另一视频并为每个帧添加其他效果的功能。我决定使用opengl-es在每个帧上应用效果。我的输入和输出视频是使用H.264编解码器的MP4。我使用MediaCodec API(Android API 18+)将H.264解码为opengl纹理,然后使用此纹理与着色器在表面上绘制。我认为将MediaCodec与H.264结合使用会在android上进行硬件解码,并且速度很快。但似乎并非如此。重新录制432x240较小的15秒视频消耗了总时间的28秒!
请查看我的代码和个人资料信息,并分享一些建议,如果我做错了事,请提出批评。
我的代码:
private void editVideoFile()
{
if (VERBOSE)
{
Log.d(TAG, "editVideoFile " + mWidth + "x" + mHeight);
}
MediaCodec decoder = null;
MediaCodec encoder = null;
InputSurface inputSurface = null;
OutputSurface outputSurface = null;
try
{
File inputFile = new File(FILES_DIR, INPUT_FILE); // must be an absolute path
// The MediaExtractor error messages aren't very useful. Check to see if the input
// file exists so we can throw a better one if it's not …Run Code Online (Sandbox Code Playgroud)