知道为什么我的列表视图的页脚总是在左边?这是我的xml布局.在添加更多数据需要时添加和删除页脚.我希望TextView和ProgressBar成为中心
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:orientation="horizontal"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="12sp"
android:textColor="@color/author_text"
android:text="LOADING DATA..."
/>
<ProgressBar
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_marginLeft="10dp"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud) 我真的很惊讶我无法在任何地方找到答案.所以这就是问题所在.
ContentResolver resolver = getContentResolver();
String[] columns = new String[]{Phone.CONTACT_ID, Phone.DISPLAY_NAME, Phone.NUMBER };
String where = Phone.NUMBER+"=?";
String[] params = new String[] {"777 777 7777"};
Cursor cursor = resolver.query(Phone.CONTENT_URI, columns, where, params, null);
while (cursor.moveToNext()) { /* So on....*/
Run Code Online (Sandbox Code Playgroud)
当params中的电话号码格式化为"777 777 7777"时,我没有记录.当它是"777-777-7777"时,它会得到记录.更糟糕的是,TelephonyManager.EXTRA_INCOMING_NUMBER给我的号码为"7777777777".如何查询此电话号码?文档说Phone.NUMBER是用户输入它的方式.好吧,这对我没有任何好处!
在自定义视图中,我可以从AttributeSet获取自定义attrs值(如下所示).但是我如何获得Android属性?例如,我如何访问android:background或android:text?不允许使用android.R.styleable.
<mine.custom.RangeSeekBar
custom:selectedMinValue="2"
custom:selectedMaxValue="4"
android:background="@drawable/my_skin" />
public RangeSeekBar(Context context, AttributeSet attrs, int defStyle) {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RangeSeekBar, defStyle, 0);
selectedMinValue = a.getInt(R.styleable.RangeSeekBar_selectedMinValue, selectedMinValue);
selectedMaxValue = a.getInt(R.styleable.RangeSeekBar_selectedMaxValue, selectedMaxValue);
minRangeValue = a.getInt(R.styleable.RangeSeekBar_minRangeValue, minRangeValue);
maxRangeValue = a.getInt(R.styleable.RangeSeekBar_maxRangeValue, maxRangeValue);
a.recycle();
}
Run Code Online (Sandbox Code Playgroud)
编辑:这是标准方式吗?
final String xmlns="http://schemas.android.com/apk/res/android";
int xmlRes = attrs.getAttributeResourceValue(xmlns, "background", -1);
String xmlText = attrs.getAttributeValue(xmlns, "text");
Run Code Online (Sandbox Code Playgroud) 我ConcurrentModificationException用这段代码得到了什么?我有一个synchronized(侦听器)锁.
private void notifyListeners(MediumRendition rendition) {
if (rendition == null) return;
synchronized (listeners) {
for (RenditionEventListener l : listeners) {
if (l.renditionType.equals(rendition.getType()) && l.mediumId == rendition.getMediumId()) {
l.listener.onRendition(rendition);
}
}
}
}
public void put(String renditionType, long mediumId, MediumRendition rendition) {
HashMap<Long, MediumRendition> l = list.get(renditionType);
if (l == null) {
l = new HashMap<Long, MediumRendition>();
list.put(renditionType, l);
}
l.put(mediumId, rendition);
notifyListeners(rendition);
}
public void addRenditionListener(String renditionType, long mediumId, RenditionListener listener) {
synchronized (listeners) {
listeners.add(new RenditionEventListener(renditionType, mediumId, …Run Code Online (Sandbox Code Playgroud)