我的应用中有一个活动,只显示搜索的一些结果.使用ListView显示此数据.这很好用.我最近尝试在其下添加Adview,但它根本不显示.更重要的是,它将我的列表视图推到屏幕顶部,这样它只能占据屏幕的前20%左右 - 只有空白.
这是显示XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myapp="http://schemas.android.com/apk/res/uk.co.redfruit.android.whogotwhat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:paddingBottom="10dp"
>
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/scanResults"
android:paddingLeft="5dp"
android:paddingRight="5dp"
/>
<com.admob.android.ads.AdView
android:id="@+id/ad"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
myapp:backgroundColor="#000000"
myapp:primaryTextColor="#FFFFFF"
myapp:secondaryTextColor="#CCCCCC"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我在这里错过了什么?
IntentFilter intentFilter = new IntentFilter("test");
registerReceiver(mReceiver, intentFilter);
Run Code Online (Sandbox Code Playgroud)
我想没有过滤器,registerReceiver(mReceiver, null)但我的应用程序崩溃了.我可以new IntentFiler()作为空文件管理器吗?
我想扩展SQLiteDataBase类,以便能够覆盖一些方法(比如rawQuery,execSQL,...)以及执行有关查询执行时间的一些统计信息.
我称之为这些功能的地方有数百个.因此,从基类SQLiteDatabase创建派生类将对我有所帮助!
问题是:在扩展SQLiteDataBase时,它无法从超类中找到任何构造函数.
import android.database.sqlite.SQLiteDatabase;
public class MySQLiteDatabase extends SQLiteDatabase
{
MySQLiteDatabase()
{
super(); // <<<--- can't find any visible constructor
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试为我的应用程序使用GPS提供程序.
该应用程序使用GPS位置提供程序查找设备的当前位置.
该应用程序工作正常.但是,虽然我的GPS_Provider已启用,但geLastKnownLocation()返回null.
MainActivity.java
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
LocationManager locationManager;
String context = Context.LOCATION_SERVICE;
locationManager = (LocationManager)getSystemService(context);
String provider = LocationManager.GPS_PROVIDER;
Location location = locationManager.getLastKnownLocation(provider);
Log.v("BEFORE", "Location is: " + location);
updateWithNewLocation(location);
Log.v("AFTER", "LOCATION FOUND");
}
private void updateWithNewLocation(Location location){
String latLongString;
TextView myLocationText;
myLocationText = (TextView)findViewById(R.id.myLocationText);
if (location != null) {
double lat = location.getLatitude();
double lng = location.getLongitude();
latLongString = "Lat:" + lat + "\nLong:" + …Run Code Online (Sandbox Code Playgroud) 我正在使用SQLite数据库.每次有1或2行值更新时,表中会有持续更新.
例如:现在TABLE1中有20行,一些行值得到更新.
我们可以知道TABLE1中哪些行已更新?
我有解决方案,但性能对我很重要.Cursor使用选择所有行的select查询注册数据观察者,当有更新时,我检索整个20行的更新值,进行编码.因此,如果有100行我需要循环所有这对于低端设备来说是一项繁琐的工作.
请帮助解决方案,如何使用游标在Android中的表中检索更新的行.
我有一个EditTextPreference定义为:
<EditTextPreference
android:defaultValue="8888"
android:key="someKey"
android:title="SomeString"
android:inputType="number"
>
Run Code Online (Sandbox Code Playgroud)
EditTextPreference在内部使用EditText,可以使用EditTextPreference.getEditText().
我想限制用户可以输入1024到65535之间整数范围的数字.我该怎么做?
我尝试使用InputFilter和TextWatcher都没有成功.
有任何想法吗?
您可能已经猜到我正在尝试验证输入网络端口.也许我应该为此使用其他类型的输入?
我想做一个吐司,我已经把EditText和一个按钮..但我不能在EditText里面输入任何东西我也不能点击按钮如何在Toast查看的EditText里面写.
public class MainActivity extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button New=(Button)findViewById(R.id.button1);
Button save=(Button)findViewById(R.id.button3);
EditText ed1=(EditText)findViewById(R.id.editText1);
final Toast t=new Toast(getApplicationContext());
New.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
ListView l=new ListView(getApplication());
l.setAdapter(new badp(getApplicationContext()));
t.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
t.setView(l);
t.setDuration(Toast.LENGTH_LONG);
t.show();
}
});
}
public class badp extends BaseAdapter
{
Context context;
private badp(Context context) {
// TODO Auto-generated constructor stub
this.context=context;
}
public int getCount() {
// TODO Auto-generated method stub …Run Code Online (Sandbox Code Playgroud)