希望这不是一个糟糕的问题,但是我已经搜索过SO并且无法找到答案.
我正在创建一个基本上是闹钟的Android应用程序.我希望主活动显示已创建的所有警报以及有关警报的一些信息.我的问题是如何根据已创建的警报数创建给定数量的文本视图.例如,如果用户创建(并且未删除)5个警报,我如何让它显示5个文本视图而不仅仅是硬编码的文本视图数?以下是我可怕的硬编码原型来测试功能(除了这个挂断).
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Launch" >
<ScrollView
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:orientation = "vertical"
android:layout_width="fill_parent"
android:layout_height="75dp"
android:text="Time"/>
<View
android:layout_width="fill_parent"
android:layout_height="0.2dp"
android:id="@+id/separator"
android:visibility="visible"
android:background="@android:color/darker_gray"/>
<TextView
android:orientation = "vertical"
android:layout_width="fill_parent"
android:layout_height="75dp"
android:text="Time"/>
<View
android:layout_width="fill_parent"
android:layout_height="0.2dp"
android:id="@+id/separator"
android:visibility="visible"
android:background="@android:color/darker_gray"/>
<TextView
android:orientation = "vertical"
android:layout_width="fill_parent"
android:layout_height="75dp"
android:text="Time"/>
<View
android:layout_width="fill_parent"
android:layout_height="0.2dp"
android:id="@+id/separator"
android:visibility="visible"
android:background="@android:color/darker_gray"/>
</LinearLayout>
</ScrollView>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
如您所见,只有三个硬编码的文本视图,而不是用户创建的许多文本视图.
再一次,我希望这不是一个问题的深度或者在其他地方有答案的问题,但我搜索它并找不到任何东西.
提前致谢!
我遇到问题让我pendingIntent着火了.我已经使用logcat等进行了一些故障排除,最后我几乎肯定我的问题实际上是在我的pendingIntent方法中.我设置的时间是正确的,并且该方法被调用,但在预定的时间没有任何事情发生.这是我用来创建的方法pendingIntent
public void scheduleAlarm(){
Log.d("Alarm scheduler","Alarm is being scheduled");
Intent changeVol = new Intent();
changeVol.setClass(this, VolumeService.class);
PendingIntent sender = PendingIntent.getService(this, 0, changeVol, 0);
AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP, time, sender);
//Toast.makeText(this, "Volume Adjusted!", Toast.LENGTH_LONG).show();
}
Run Code Online (Sandbox Code Playgroud)
这是服务类:
public class VolumeService extends Service{
@Override
public void onCreate() {
super.onCreate();
Log.d("Service", "Service has been called.");
Toast.makeText(getApplicationContext(), "Service Called!", Toast.LENGTH_LONG).show();
}
@Override
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
return null;
}
}
Run Code Online (Sandbox Code Playgroud)
scheduleAlarm()班级中的日志按照我的计划运行,但后来没有任何反应,所以我认为它是我的 …
service android alarmmanager android-intent android-pendingintent
我试图找到一种方法,可以SSID在Android设备上获取记住的网络列表。
我看到一些线程在问类似的问题。但是,我发现的几个问题试图获取已知的网络密码SSIDS,而不是,密码的答案是:
1)如果没有root,您将无法获得它们,并且
2)根据设备,它们存储在不同的位置。
有什么方法可以让我做到这一点?
android ×3
java ×2
alarmmanager ×1
eclipse ×1
listview ×1
scrollview ×1
service ×1
textview ×1
wifi ×1