我刚刚实施了新的RecyclerView.我想用它来显示用户的消息(短信).
我阅读了官方文档,这RecyclerView是一个新的和改进的ListView(类似的东西),我们应该使用它来获得更好的性能.
一切都很顺利,直到我想显示用户的对话,我希望从底部开始显示消息.在ListView我通常使用的android:stackFromBottom="true",但当我尝试它时,RecyclerView它不起作用(即使没有收到任何错误).
有谁知道如何使这些RecyclerView物品从底部堆叠?谢谢.
Lollipop关于键盘高度的变化是什么?
我有一个方法,使用getViewTreeObserver()正确的方法返回Lollipop之前的每个版本的键盘高度(在ldpi,mdpi,hdpi和xhdpi测试 - 没有问题)但似乎在Lollipop上返回的高度比真正的键盘大一点点高度.
在我的华硕Nexus 7上,我的高度比实际高度大约70 px.
有人知道如何在Lollipop上获得真正的键盘高度吗?
keyboard height android android-4.4-kitkat android-5.0-lollipop
我有一个活动,我写了一个插入数据库的名称.在另一个活动中,我想放置一个ListView,它使用数据库中的那些名称填充,或者在我从第一个活动的edittext中写入时直接添加新项目.我意识到插入到数据库部分,但我无法弄清楚如何填充该listview.
public class Add extends Activity implements OnClickListener{
Button sqlUpdate;
EditText sqlName;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.add);
sqlUpdate = (Button) findViewById(R.id.bFinishAdd);
//sqlView = (Button) findViewById(R.id.bSQLopenView);
sqlName = (EditText) findViewById(R.id.etAdd);
sqlUpdate.setOnClickListener(new OnClickListener(){
public void onClick(View arg0) {
// TODO Auto-generated method stub
boolean didItWork = true;
try{
String name = sqlName.getText().toString();
DBhelp entry = new DBhelp(Add.this);
entry.open();
entry.createEntry(name);
entry.close();
Intent i = new Intent(Add.this, Liste.class);
startActivity(i);
}catch(Exception i){
didItWork = false;
}finally{
} …Run Code Online (Sandbox Code Playgroud) 我有一个警报,在特定时间发送通知(如果在那一天有联系人的生日).
我需要的是,当我设置闹钟时,它应该在同一天和同一时间每年重复一次.我怎么能这样做?
Intent myIntent = new Intent(Main.this, MyAlarmService.class);
pendingIntent = PendingIntent.getService(Main.this, 0, myIntent, 0);
AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(System.currentTimeMillis());
cal.clear();
cal.set(2012,5,20,18,40);
alarmManager.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), pendingIntent);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), 60*60*24*365*1000, pendingIntent);
Run Code Online (Sandbox Code Playgroud)
这是AlarmService:
public class MyAlarmService extends Service {
static final int uniqueID = 1394885;
private PendingIntent pendingIntent;
@Override
public void onCreate() {
// TODO Auto-generated method stub
Toast.makeText(this, "MyAlarmService.onCreate()", Toast.LENGTH_LONG).show();
}
@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
Toast.makeText(this, "MyAlarmService.onBind()", Toast.LENGTH_LONG).show();
return null;
}
@Override …Run Code Online (Sandbox Code Playgroud)