我正在尝试使用Picasso库将外部图像加载到一行中ListView.我有一个ArrayAdapter如下习惯:
public class RevisedBusinessesAdapter extends ArrayAdapter<HashMap<String, String>> {
Context context;
int layoutResourceId;
ArrayList<HashMap<String, String>> data = null;
public RevisedBusinessesAdapter(Context context, int layoutResourceId, ArrayList<HashMap<String, String>> data) {
super(context, layoutResourceId, data);
this.layoutResourceId = layoutResourceId;
this.context = context;
this.data = data;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
RevisedBusinessHolder holder = null;
if (row == null) {
LayoutInflater inflater = ((Activity) context).getLayoutInflater();
row = inflater.inflate(layoutResourceId, parent, false);
holder = new RevisedBusinessHolder(); …Run Code Online (Sandbox Code Playgroud) 当你这样做时,例如,
Linkify.addLinks(mTextView, Linkify.EMAIL_ADDRESSES);
Run Code Online (Sandbox Code Playgroud)
Linkify使用什么颜色?它在android.graphics.Color中并不明显.
我有一些很长的段落,我只想要标准链接,还有一个我需要自己做的东西,我想看起来一样,但我无法弄清楚要设置它的颜色.我可以回忆所有其他人,但这似乎还有很长的路要走.
我有一个显示网页的活动.在某些手机(例如,华为Ascend)上,此活动以导致应用程序重新启动的方式崩溃,但不会导致通常的android错误弹出窗口进行报告.(其他手机(例如Nexus)根本不会崩溃.)它似乎总是在网页加载时崩溃,但不会在任何特定点崩溃,例如有时在shoulOverrideUrlLoading,有时在onPageStarted或onPageFinished期间.
我认为WebView正在引起这种情况 -
08-29 21:08:22.577:A/libc(957):致命信号11(SIGSEGV)位于0x00000008(代码= 1),线程957
- 但我无法理解为什么.
这是活动:
public class WebDisplay extends Activity
{
private String sentUrl = "";
public WebView myWebView;
public ProgressBar spinner;
@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate (Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Log.d("WEBVIEW", "onCreate");
getWindow().setBackgroundDrawableResource(R.color.white);
Bundle extras = getIntent().getExtras();
if (null != extras)
{
sentUrl = extras.getString("displayURL");
}
setContentView(R.layout.webdisplay);
myWebView = (WebView) findViewById(R.id.webDisplay);
spinner = (ProgressBar) findViewById(R.id.webLoading);
// WebView displays default to showing things in exact pixel size at 100%
// resolution, meaning it generally opens on …Run Code Online (Sandbox Code Playgroud) Android手机上的联系人提供了"过滤联系人"等设置,允许用户设置"仅显示具有电话号码的联系人"和"仅显示在线联系人"等内容,以及要显示的联系人集(例如,仅手机,手机和谷歌等).
这样做的时候
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType(ContactsContract.Contacts.CONTENT_TYPE);
startActivityForResult(intent, PICK_CONTACT);
Run Code Online (Sandbox Code Playgroud)
有没有办法让这些过滤器应用于联系人列表?默认情况下它似乎返回一切.如果你不能,有没有办法访问这些设置,看看它们是什么,所以我可以建立自己的联系人选择器列表,以匹配手机用户设置默认值的方式?这只需要适用于Android 2.
(理想的选择是调用联系人选择器的方法,让用户也可以在那里设置过滤器.)
我想添加相同的水平滚动行按钮,如此
<HorizontalScrollView [...]>
<LinearLayout [...] android:orientation="horizontal">
<Button android:id="@+id/btn1" [..] />
<Button [..] />
[...]
</LinearLayout>
</HorizontalScrollView>
Run Code Online (Sandbox Code Playgroud)
(toolbar.xml)到我的应用程序中每个活动的底部.我不想在每个活动中为每个按钮指定点击监听器,而是希望能够在一个地方完成所有这些操作,然后每次只导入控件.我想我可以做点什么
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.example.ButtonBar android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_alignParentBottom="true"
android:layout_below="@+id/pagecontent" />
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/pagecontent">
<!-- the rest of each activity's xml -->
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
在屏幕上包含按钮栏,然后执行类似的操作
package com.example;
import android.content.Context;
import android.content.Intent;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.HorizontalScrollView;
public class ButtonBar extends HorizontalScrollView implements OnClickListener
{
public ButtonBar(Context context, AttributeSet attrs)
{
super(context, attrs);
LayoutInflater inflater = …Run Code Online (Sandbox Code Playgroud) 我有这样的自定义视图
public class ButtonBar extends HorizontalScrollView
{
public View mButtonRows;
public ButtonBar(Context context, AttributeSet attrs)
{
super(context, attrs);
LayoutInflater inflater = (LayoutInflater)
context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mButtonRows = inflater.inflate(R.layout.toolbar, null);
// button click handling code goes here
addView(mButtonRows);
}
}
Run Code Online (Sandbox Code Playgroud)
这包含在我的主要xml中
<com.example.ButtonBar
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="@+id/pagecontent" />
Run Code Online (Sandbox Code Playgroud)
并膨胀像这样的xml文件:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ButtonsRow"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/button1"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_weight="0.3"
android:text="button1"
/>
<Button
android:id="@+id/button2"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_weight="0.3"
android:text="button2"
/>
<Button
android:id="@+id/button3"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_weight="0.3"
android:text="button3"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
(它目前只有三个按钮,但在更高版本中将需要更多按钮,因此HorizontalScrollView.)
查看hierarchyviewer,自定义视图看起来似乎是屏幕宽,但LinearLayout只有它所包含的按钮宽(当前按钮大小约为屏幕的2/3),尽管设置了fill_parent宽度; 按钮不伸展.如果我将LinearLayout的背景设置为@android:drawable/bottom_bar(这是屏幕宽度的png),则按钮会正确调整大小; …