我正在尝试用两列制作gridview.我的意思是每排并排两张照片,就像这张照片一样.
但是我的照片之间有空格,因为它的大小不一样.这是我得到的.
如您所见,第一张图片隐藏了显示联系人姓名和电话号码的图例.而其他图片未正确拉伸.
这是我的GridView xml文件.如您所见,columnWidth
设置为200dp.我希望它是自动的,所以图片会自动调整每个屏幕尺寸的大小.
<?xml version="1.0" encoding="utf-8"?>
<GridView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridViewContacts"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:numColumns="2"
android:columnWidth="200dp"
android:stretchMode="columnWidth"
android:gravity="center" />
Run Code Online (Sandbox Code Playgroud)
这是项目xml文件,它代表每个项目本身.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/imageViewContactIcon"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY" />
<LinearLayout
android:id="@+id/linearlayoutContactName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="5dp"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:background="#99000000"
android:layout_alignBottom="@+id/imageViewContactIcon">
<TextView
android:id="@+id/textViewContactName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:textStyle="bold"
android:textSize="15sp"
android:text="Lorem Ipsum" />
<TextView
android:id="@+id/textViewContactNumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:layout_marginLeft="5dp"
android:focusable="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:textSize="10sp"
android:text="123456789" />
</LinearLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
所以我想要的是每行显示两个图像,并且无论屏幕大小如何,图像都会自动调整大小.我在布局上做错了什么?
谢谢.
我在Ubuntu 10.04上使用Eclipse Helios,我正在尝试在其上安装CDT插件.我从这里下载它这里.
然后我去安装新软件并选择zip文件(我不提取它,只需选择zip文件).它确定,它安装,一切正常,它显示可选功能,等等等等等等.
然后我创建了一个新的HelloWorld项目.当我尝试运行它时,它会显示错误并说:
发射失败.找不到二进制文件.
任何人都可以解释我如何解决它?
谢谢.
我有一个ASP.NET Web API,在使用localhost:1783在"IIS Express"上运行时可以正常工作
但当我没有"使用IIS Express"然后按"创建虚拟目录"时......
...我刚收到404错误:
任何想法都错了吗?谢谢!
我应该在哪里调用代码上的close()?
LogCat返回此错误:
从未在数据库android.database.sqlite.DatabaseObjectNotClosedException上显式调用close():应用程序未关闭此处打开的游标或数据库对象
错误是这样的:
> 12-16 17:24:50.886: ERROR/Database(10982): close() was never explicitly called on database '/data/data/com.psyhclo/databases/calls.db'
12-16 17:24:50.886: ERROR/Database(10982): android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here
12-16 17:24:50.886: ERROR/Database(10982): at android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1827)
12-16 17:24:50.886: ERROR/Database(10982): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:820)
12-16 17:24:50.886: ERROR/Database(10982): at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:854)
12-16 17:24:50.886: ERROR/Database(10982): at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:847)
12-16 17:24:50.886: ERROR/Database(10982): at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:541)
12-16 17:24:50.886: ERROR/Database(10982): at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:203)
12-16 17:24:50.886: ERROR/Database(10982): at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:118)
12-16 17:24:50.886: ERROR/Database(10982): at com.psyhclo.CallDataHelper.<init>(CallDataHelper.java:27)
12-16 17:24:50.886: ERROR/Database(10982): at com.psyhclo.RatedCalls.fillList(RatedCalls.java:66)
12-16 17:24:50.886: …
Run Code Online (Sandbox Code Playgroud) 我正在尝试在真实设备上调试我的应用程序,但是我收到此错误:
ERROR/AndroidRuntime(981):引起:java.lang.IllegalArgumentException:列'_id'不存在
当我在模拟器上进行测试时,不会出现错误.错误在以下代码的最后一行中给出:
adapter = new SimpleCursorAdapter(this, R.layout.list_item, c, new String[] {
DataHandlerDB.CONTACT_NAME_COL,
DataHandlerDB.CONTACT_NUMBER_COL,
DataHandlerDB.CONTACT_DURATION_COL,
DataHandlerDB.CONTACT_DATE_COL }, new int[] {
R.id.contact_name, R.id.phone_number, R.id.duration, R.id.date });
Run Code Online (Sandbox Code Playgroud)
这是我的活动:
public class MyActivity extends Activity {
private static final String LOG_TAG = "MyActivity";
private ListView listview;
private SimpleCursorAdapter adapter;
private DataHandlerDB handler;
private SQLiteDatabase db;
private OpenHelper helper;
private Cursor c;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
helper = new OpenHelper(this);
db = helper.getWritableDatabase();
helper.onCreate(db);
setBasicContent();
c.close();
}
@Override
public void onDestroy(){ …
Run Code Online (Sandbox Code Playgroud) 我在我的应用程序中使用TabHost,我在我的应用程序中使用了四个选项卡,当我选择特定选项卡而未选中时,我想在TabHost中使用不同的图像.我需要为每个特定标签使用不同的图像.
当我选择任何标签时,图像有点亮,当我切换到另一个标签时,明亮的图像变为灰色阴影.
我已经实现了TabHost,但我不知道如何更改TabHost中的图像.
任何人都可以帮助我.
谢谢,大卫
我正在使用ubuntu 64位并尝试在NASM上运行.asm文件.但是当我尝试运行以下代码时它会返回此错误.我想要做的是通过从源代码编译(或汇编)目标文件来构建可执行文件
$ nasm -f elf hello.asm
,然后在创建文件后hello.o
通过调用链接器从目标文件生成可执行文件本身
$ ld -s -o hello hello.o
Run Code Online (Sandbox Code Playgroud)
这将最终构建hello可执行文件.
我正在关注这个教程http://www.faqs.org/docs/Linux-HOWTO/Assembly-HOWTO.html
错误:
输入文件`hello.o'的i386体系结构与i386:x86-64输出不兼容
码:
section .data ;section declaration
msg db "Hello, world!",0xa ;our dear string
len equ $ - msg ;length of our dear string
section .text ;section declaration
;we must export the entry point to the ELF linker or
global _start ;loader. They conventionally recognize _start as their
;entry point. Use ld -e foo to override the default.
_start:
;write our …
Run Code Online (Sandbox Code Playgroud) 我想知道是否有办法知道呼叫的内容提供商是否已经改变.我的意思是,如果我拨打电话,或者我接听电话,它会返回一个"标志",表示已将新日志添加到呼叫日志中,或者Android存储有关呼叫的信息的位置.
因为,当我拨打电话时,Android会在内容提供商中存储号码,联系人姓名(如果存在),通话时间,持续时间等等.那么有没有办法捕获这个"标志",表示呼叫的内容提供商更大,我的意思是,在内容提供商CallLog.Calls上插入了新数据.
所以,我仍然对这个问题有很多怀疑.我不知道在哪里注册内容观察者.我的意图是,当CallLog内容提供程序中的某些内容发生更改时,将使用代码的insert方法.
我的意思是,除非将新数据添加到CallLog内容提供程序,否则代码将不会执行任何操作.如果已将某些数据添加到CallLog内容提供程序,则代码将查询新数据,然后将插入.我想这样做,因为没有内容观察者,应用程序在每次运行应用程序时已经插入的数据库中插入数据,得到了吗?
所以这是我的代码.如果有人可以告诉我放在哪里registerContentObserver()
以及其他所需的东西.
public class RatedCalls extends ListActivity {
private SQLiteDatabase db;
private CallDataHelper dh = null;
StringBuilder sb = new StringBuilder();
OpenHelper openHelper = new OpenHelper(RatedCalls.this);
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Cursor cursor = getContentResolver().query(
android.provider.CallLog.Calls.CONTENT_URI, null, null, null,
android.provider.CallLog.Calls.DATE + " DESC ");
dh = new CallDataHelper(this);
db = openHelper.getWritableDatabase();
startManagingCursor(cursor);
int numberColumnId = cursor.getColumnIndex(android.provider.CallLog.Calls.NUMBER);
int durationId = cursor.getColumnIndex(android.provider.CallLog.Calls.DURATION);
int contactNameId = cursor.getColumnIndex(android.provider.CallLog.Calls.CACHED_NAME);
int dateId = cursor.getColumnIndex(android.provider.CallLog.Calls.DATE);
int numTypeId = cursor.getColumnIndex(android.provider.CallLog.Calls.CACHED_NUMBER_TYPE);
Date dt …
Run Code Online (Sandbox Code Playgroud) 嘿我想创建一个带有AUTO_INCREMENT列的数据库.但我不知道如何解析方法插入中的值.我只是不知道要解析一个AUTO_INCREMENT参数,我解析了1应该是auto_increment,但我知道它不是我应该解析的.
这是CallDatHelper.java类,我在其中声明方法insert,以及创建数据库的方法.
package com.psyhclo;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteStatement;
import android.util.Log;
import java.util.ArrayList;
import java.util.List;
public class CallDataHelper {
private static final String DATABASE_NAME = "calls.db";
private static final int DATABASE_VERSION = 1;
private static final String TABLE_NAME = "contact_data";
private Context context;
private SQLiteDatabase db;
public CallDataHelper(Context context) {
this.context = context;
OpenHelper openHelper = new OpenHelper(this.context);
this.db = openHelper.getWritableDatabase();
}
public boolean insert(Integer cId, String cName, String numType,
String cNum, String …
Run Code Online (Sandbox Code Playgroud) 嘿,我正在尝试为一个看起来像(并且大多数就像)调用日志的列表创建一个设计,如下所示:
为此,我下载了源代码,我正在研究它以了解哪个类和xml文件实现它.
我发现这两个xml文件recent_calls_list_item.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="?android:attr/listPreferredItemHeight"
android:paddingLeft="7dip">
<com.psyhclo.DontPressWithParentImageView
android:id="@+id/call_icon" android:layout_width="wrap_content"
android:layout_height="match_parent" android:paddingLeft="14dip"
android:paddingRight="14dip" android:layout_alignParentRight="true"
android:gravity="center_vertical" android:src="@android:drawable/sym_action_call"
android:background="@drawable/call_background" />
<include layout="@layout/recent_calls_list_item_layout" />
Run Code Online (Sandbox Code Playgroud)
另一个是recent_calls_list_item_layout.xml:
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<View android:id="@+id/divider"
android:layout_width="1px"
android:layout_height="match_parent"
android:layout_marginTop="5dip"
android:layout_marginBottom="5dip"
android:layout_toLeftOf="@id/call_icon"
android:layout_marginLeft="11dip"
android:background="@drawable/divider_vertical_dark"
/>
<ImageView android:id="@+id/call_type_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_marginLeft="4dip"
/>
<TextView android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/divider"
android:layout_alignParentBottom="true"
android:layout_marginBottom="8dip"
android:layout_marginLeft="10dip"
android:textAppearance="?android:attr/textAppearanceSmall"
android:singleLine="true"
/>
<TextView android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:layout_marginLeft="36dip"
android:layout_marginRight="5dip"
android:layout_alignBaseline="@id/date"
android:singleLine="true"
android:ellipsize="marquee"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textStyle="bold"
/>
<TextView android:id="@+id/number" …
Run Code Online (Sandbox Code Playgroud)