我想创建一个像真正的后退按钮一样工作的按钮.当我按下后退按钮(我的按钮)时,这与真正的按钮相同.我如何以编程方式进行操作?
所以,在我的Dialog中,我有一个启动Asynctask下载器的按钮,从我的服务器获取一些文件; 这工作得很好.但是,我想解除当前的Dialog并显示单击按钮上的ProgressDialog.我该如何处理这个问题?
目前,如果我点击按钮(我的Dialog中的一个元素),整个用户界面会在下载器从服务器下载文件时冻结.下载程序完成任务后,将显示进度对话框.
我的代码看起来像这样
MainActivity{
Dialog dialog;
ProgressDialog progress;
onCreate(){
dialog = new Dialog(this);
progress = new ProgressDialog(this);
dialog.setContentView(Some View Resource With My Button);
someMethod();
dialog.show();
}
someMethod(){
Button button = (Button) dialog.findViewById(resource of button);
button.setOnClickListener(new OnClickListener(){
onClick(){
dialog.dismiss();
progress.show();
new DownloaderAsyncTask(progress).execute().get();
}
//go to another activity when download finished
});
}
private class DownloaderAsyncTask extends AsyncTask<Void, Void, Void>{
ProgressDialog progress;
DownloaderAsyncTask(ProgressDialog progress){
this.progress = progress;
}
doInBackGround(){
//Downloading
}
onPostExecute(){
//Kill connection
this.progress.dismiss();
}
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢.如果您需要任何其他信息,请告诉我.
我在我的应用程序中使用了ActionBarSherlock来为蜂窝设备提供ActionBars.我想在Light.DarkActionBar主题中使用,如何为ActionBar的各个部分自定义以下内容(见图)

我尝试使用以下设置,虽然我取得了一些成功,但结果却看起来并不像预期的那样,
<item name="android:background">@drawable/bg_title_bar</item>
<item name="background">@drawable/bg_title_bar</item>
<item name="actionModeSplitBackground">@drawable/bg_tab_bar</item>
<item name="android:actionModeSplitBackground">@drawable/bg_tab_bar</item>
Run Code Online (Sandbox Code Playgroud)
我应该使用哪些其他设置?谢谢!!
我想创建一个类似于gmail应用的进度条(中间进度条),它会更改颜色。我可以通过从sdk / platforms保留并更新progress_indeterminate_horizontal.xml来实现此目的。我不想使用动画(多色图像)。我想使用xml来实现这一点(我想使用渐变)。任何帮助将不胜感激。
提前致谢
我在活动中使用listview和slidedrawer.我的目的是打开slidedrawer并在列表项单击时显示内容.slidedrawer内容将根据所选项目进行更改.
UI布局如下所示.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ListView
android:id="@+id/presentation_list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
<SlidingDrawer
android:id="@+id/slidingDrawer1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:content="@+id/content"
android:handle="@+id/handle"
android:orientation="horizontal" >
<Button
android:id="@+id/handle"
android:layout_width="40dp"
android:layout_height="fill_parent"
android:background="@android:color/darker_gray" />
<LinearLayout
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Presentation's Images.. Please Flip"
android:textColor="@android:color/black"
android:textStyle="bold" />
<ImageView
android:id="@+id/content_imageview"
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="@android:color/black"
android:layout_below="@id/presentation_list"
/>
</LinearLayout>
</SlidingDrawer>
Run Code Online (Sandbox Code Playgroud)
我点击listview滑块打开,当我点击slidedrawer的imageview时,我的listview也被点击了.控件进入listview项目单击方法并且图像被更改
任何人都可以帮我纠正这个问题吗?
我想强制将图标放在Android的分割操作栏的底栏中,同时确保顶部操作栏保持为空.我已经做了很多实验,但还是没能弄清楚如何做到这一点.
我确信这是可能的,因为我已经在Google地图应用中看到了它.见下图:
在我的UI中,我使用图像按钮进行各种操作.在xml文件中如下
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/homebtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Home"
android:scaleType="fitCenter"
android:src="@drawable/homebutton"
android:onClick="onHomeBtn"
/>
<ImageButton
android:id="@+id/backbtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Back"
android:scaleType="fitCenter"
android:src="@drawable/backbutton"
android:onClick="onBackBtn"
/>
<TextSwitcher
android:id="@+id/infomsg"
android:layout_width="550dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" />
<ImageButton
android:id="@+id/exitbtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Exit"
android:scaleType="fitCenter"
android:onClick="onExitBtn"
android:src="@drawable/exitbutton"
/>
Run Code Online (Sandbox Code Playgroud)
图像显示了ui的输出.按钮中的图像未完全覆盖.我不需要按钮边框.怎么可能?

我不确定为什么,但我试图设置我的缩略图的大小来填充父母,但它似乎没有出现他们这样做,我不确定为什么.
我已将参数设置为(我相信)它们应该是,但缩略图仍然不会延伸到屏幕的边缘.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:autoLink="web"
android:textStyle="bold" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/groupScrollView">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<com.google.android.youtube.player.YouTubePlayerView
android:id="@+id/youtubeplayerview"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/textView1a"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Throw 'Em Up"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textView2a"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="by DJ Generic"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/textView3a"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="100,000 views"
android:textAppearance="?android:attr/textAppearanceSmall" />
<com.google.android.youtube.player.YouTubeThumbnailView
android:id="@+id/youtubethumbnailview1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dp" />
<TextView
android:id="@+id/textView1b"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Bulls On Parade"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textView2b"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="by Rage …Run Code Online (Sandbox Code Playgroud) 当我点击它时,如何让我的ImageButton改变它的颜色?
我想做这样的事情:
按钮(蓝色) - >单击 - >按钮(红色) - >单击 - >按钮(蓝色) - >单击 - >按钮(红色)
当我点击它切换颜色,当我再次点击它回到原始.
我试过这样做:
mTrashFlag = !mTrashFlag;
ImageButton bt = (ImageButton)findViewById(R.id.trash_button);
if(!mTrashFlag)
{
bt.setBackgroundColor(0x4CB8FB);
}
else
{
bt.setBackgroundColor(0xff0000);
}
Run Code Online (Sandbox Code Playgroud)
但它没有用.它将颜色变为白色,然后我无法再次点击它.
我看过一些应用程序使用这种外观,我认为它看起来很棒所以我希望我的应用程序看起来也像这样.
我已经尝试制作一个ListView并使用"simple_list_item_1",但这只是一个带有白色文本的纯黑色背景.
此外,我的应用程序可以看起来像仍然可用于Android 2.1及以上?