我正在开发一个应用程序,我必须使用viewpager,在viewpager中的所有项目完成后,我必须调用一个活动.我无法为此获得事件监听器.这也是我一直在推荐的内容:https: //github.com/chiuki/android-swipe-image-viewer/blob/master/src/com/sqisland/android/swipe_image_viewer/MainActivity.java
这是我到目前为止所做的:
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager);
ImagePagerAdapter adapter = new ImagePagerAdapter();
viewPager.setAdapter(adapter);
OnPageChangeListener mListener = new OnPageChangeListener() {
@Override
public void onPageSelected(int arg0) {
// TODO Auto-generated method stub
}
@Override
public void onPageScrolled(int arg0, float arg1, int arg2) {
}
@Override
public void onPageScrollStateChanged(int arg0) {
Log.i("Doing something here", "On Scroll state changed");
}
};
viewPager.setOnPageChangeListener(mListener);
}
private class ImagePagerAdapter extends …Run Code Online (Sandbox Code Playgroud) 我正在尝试为Android构建Chromium开源浏览器.我提到过:
访问:http://code.google.com/p/chromium/wiki/AndroidBuildInstructions
但是,我认为它只会构建测试包而不是完整的浏览器.任何想法如何让我在我的设备上运行它来通过源代码对其进行一些更改.
我按照建议从Git检查了代码,并使用depot_tools并将操作系统定位为android来相应地构建它.所有的构建环境都是正确的,我可以制作"make -j4"命令.但仍然无法使用eclipse源代码进行一些更改.
我怎样才能改变?
请帮我解决这个问题.
我一直在努力AutoCompleteTextView.当我们输入时,我能够在下拉列表中获得建议和所有建议.

我的问题是:我们可以在建议下拉列表中突出显示键入的字符吗?
我正在开发一个应用程序,我必须将drawable放在操作栏的顶部,然后不时更新.这是我希望它看起来像的布局.

我想把一个drawable如图所示(绿色可绘制而不是通知的东西).这有可能在Android中实现这种屏幕吗?如果,那么请指导我如何实现这一目标.
任何形式的帮助将不胜感激.
我正在开发一个应用程序,我必须在单击按钮时显示快速操作对话框.以下是我希望如何实现的示例.

直到现在我无法弄清楚如何制作自定义快速操作对话框.但我尝试过使用一项活动,以及一些我接近实现的目标.这是我到目前为止所做的.
点击按钮我将意图传递给活动:
if (v.getId() == R.id.points) {
Toast.makeText(MainActivity.this, "Clicked on points",
Toast.LENGTH_SHORT).show();
Intent i = new Intent(MainActivity.this, PointsActionMenu.class);
startActivity(i);
}
Run Code Online (Sandbox Code Playgroud)
我曾经习惯styles.xml让活动透明化.
Styles.xml
<style name="Theme.Transparent" parent="android:Theme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">false</item>
</style>
Run Code Online (Sandbox Code Playgroud)
实现这些东西我在屏幕上有这个UI.

现在,我有两个问题:
答案中的任何一个都可以帮助我.
任何形式的帮助将不胜感激.
我正在构建一个使用搜索引擎搜索网络的应用.我的应用程序中有一个edittext,用户将从中搜索网页.我想像浏览器历史一样保存搜索关键字.我可以使用最后一个关键字保存并显示它,但我不能增加搜索结果的数量.我想显示最近的5个searhes.这是我的代码:
public class MainActivity extends Activity implements OnClickListener {
Button insert;
EditText edt;
TextView txt1, txt2, txt3, txt4, txt5;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
edt = (EditText) findViewById(R.id.search_word);
txt1 = (TextView) findViewById(R.id.txt1);
txt1.setOnClickListener(this);
insert = (Button) findViewById(R.id.insert);
insert.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if ((edt.getText().toString().equals(""))) {
Toast.makeText(
getBaseContext(),
"Whoa! You haven't entered anything in the search box.",
Toast.LENGTH_SHORT).show();
} else {
SharedPreferences app_preferences = PreferenceManager
.getDefaultSharedPreferences(MainActivity.this);
SharedPreferences.Editor editor = app_preferences.edit();
String text = edt.getText().toString();
editor.putString("key", …Run Code Online (Sandbox Code Playgroud) 我正在编辑我的问题,以便更好地理解我需要的东西,因为下面的答案没有给我正确的解决方案.所以,我要做的是使用底部的中性按钮创建一个自定义警报对话框.以下是它应该是什么样子的示例:

直到现在我已经使用xml和更改活动的自定义对话框android:theme="@android:style/Theme.Holo.Light.Dialog",所以我可以得到相同的外观和感觉.这是我的xml代码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/dialog"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/login_prompt_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:text="@string/login_prompt_rewards_header"
android:textSize="17sp"
android:textStyle="bold" >
</TextView>
<TextView
android:id="@+id/login_prompt_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/login_prompt_header"
android:layout_marginTop="5dp"
android:gravity="center_vertical|center_horizontal"
android:paddingLeft="18dp"
android:paddingRight="18dp"
android:text="@string/login_prompt_rewards_text"
android:textSize="15sp" >
</TextView>
<Button
android:id="@+id/log_in"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/login_prompt_text"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:layout_marginTop="15dp"
android:background="@drawable/log_in"
android:contentDescription="@string/none" >
</Button>
<Button
android:id="@+id/create_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/log_in"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:background="@drawable/create_account"
android:contentDescription="@string/none" >
</Button>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
通过上面的布局我得到了以下结果:

我面临的问题是:如何在自定义对话框中设置中性按钮?我对此并不了解.如果您对我的问题有疑问或者您无法理解该语言,请发表评论,以便我再次给您一个清晰的想法.帮助将不胜感激.
我正在我的应用程序中嵌入GCM以进行推送通知.我面临一个非常奇怪的问题,在第一次运行时我无法获得GCM注册令牌,但是当您第二次运行我的应用程序时,您将在控制台上打印注册ID.我不知道我在做什么.这是我到目前为止所做的.
这是我想要打印GCM regID的onCreate()方法:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final String regId = GCMRegistrar.getRegistrationId(this);
GCM_regID = regId;
System.out.println("GCM regId: "+GCM_regID);
Run Code Online (Sandbox Code Playgroud)
在onCreate()中执行以下代码:
/**
* Google Cloud Messaging - Getting server Url and device ID to send it
* across Google server for the notification..
*/
mGCMReceiver = new GCMReceiver();
mOnRegisteredFilter = new IntentFilter();
mOnRegisteredFilter.addAction(Constants.ACTION_ON_REGISTERED);
if (Constants.SENDER_ID == null) {
// mStatus.setText("Missing SENDER_ID");
return;
}
if (Constants.SERVER_URL == null) {
// mStatus.setText("Missing SERVER_URL");
return;
}
GCMRegistrar.checkDevice(this);
GCMRegistrar.checkManifest(this);
if (!regId.equals("")) { …Run Code Online (Sandbox Code Playgroud) 我需要解析一些JSON对象,看起来像这样:
{"searchdata":{},"userdata":{"currency":"69","notificationCount":7}}
Run Code Online (Sandbox Code Playgroud)
我使用以下代码来实现此目的:
JSONObject rootObj = new JSONObject(getResponse);
JSONObject jSearchData = rootObj.getJSONObject("searchdata");
JSONObject userData = jSearchData.getJSONObject("userdata");
String currency = userData.getString("currency");
Run Code Online (Sandbox Code Playgroud)
我无法currency从上面的代码打印对象.我一直异常:
Exception: org.json.JSONException: No value for userdata
Run Code Online (Sandbox Code Playgroud)
我不知道我做错了什么.
任何形式的帮助将不胜感激.
我正在开发一个应用程序,用于webview加载某些网站。我还定制了actionbar网站导航button。这是我的布局的视图:

当我加载网站时,我的所有三个按钮都是可见的,但我希望它们仅在用户单击某个 URL 时才可见,以便用户轻松理解这些按钮的用途。
我已将所有功能添加到这些按钮中。这是我的代码:
website_back = (ImageButton) cView.findViewById(R.id.website_back);
website_forward = (ImageButton) cView.findViewById(R.id.website_forward);
website_refresh = (ImageButton) cView.findViewById(R.id.website_refresh);
if (v.getId() == R.id.website_back) {
webview.goBack();
}
if (v.getId() == R.id.website_forward) {
webview.goForward();
}
if (v.getId() == R.id.website_refresh) {
webview.reload();
}
Run Code Online (Sandbox Code Playgroud)
我的网络视图客户端:
private class HelloWebViewClient extends WebViewClient {
public void onPageStarted(WebView view, String url, Bitmap favicon) {
progress.setVisibility(View.VISIBLE);
super.onPageStarted(view, url, favicon);
}
public void onPageFinished(WebView view, String url) {
progress.setVisibility(View.GONE);
super.onPageFinished(view, url);
}
public boolean shouldOverrideUrlLoading(WebView view, …Run Code Online (Sandbox Code Playgroud)