Edit3:我自己的项目列表布局:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:gravity="center_vertical"
/>
Run Code Online (Sandbox Code Playgroud)
Edit2:老实说,我可能只是创建一个为每个文件创建按钮的for循环.这是值得花时间的头痛.
编辑:我想强调一下这样一个事实:我将我的确切代码复制+粘贴到一个新的测试应用程序中,它运行正常.这可能会给你们一个线索.
经过大量的调试,我已经缩小了一个问题.我正在尝试将项目(文件)添加到ArrayList,然后将其放入ArrayAdapter,最后在ListView中显示项目.问题是只显示第一个添加的项目.
这是我试图这样做的方式:
ListView listView = (ListView) view.findViewById(R.id.templateFilesList);
ArrayList<String> templateList = new ArrayList<>();
File myDir = getContext().getFilesDir();
File[] templateFiles = myDir.listFiles();
int length = templateFiles.length;
for(int i = 0; i < length; i++){
templateList.add(templateFiles[i].getName());
}
ArrayAdapter arrayAdapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_list_item_1,
templateList);
listView.setAdapter(arrayAdapter);
Run Code Online (Sandbox Code Playgroud)
templateFiles []数组正确获取内部存储中的8个文件(通过logcat/debugger确认),但只有第一个项目显示在ListView中.这里有一个更清晰的问题:
// If I replace the for loop with this:
templateList.add(templateFiles[1].getName());
templateList.add(templateFiles[0].getName());
Run Code Online (Sandbox Code Playgroud)
仅显示templateFiles [1].同样,如果我这样做:
templateList.add(templateFiles[0].getName());
templateList.add(templateFiles[1].getName());
Run Code Online (Sandbox Code Playgroud)
仅显示templateFiles [0].什么出问题的任何想法?
这是我的XML:
<LinearLayout …Run Code Online (Sandbox Code Playgroud) 我对这个MPAndroid 图表库有点迷茫。
我在这里开始了初学者示例,它建议使用 getValueX() 和 getValueY() 方法创建一个对象数组/列表,然后将其添加为条目,如下所示:
List<Entry> entries = new ArrayList<Entry>(); // entry list
for(ValueAndDateObject data : valueAndDateArrayList){
// valueAndDateArrayList is the list of my own data
//(objects with a String X-value, and a double Y-value)
entries.add(new Entry(data.getValueX(), data.getValueY())); //error here
}
Run Code Online (Sandbox Code Playgroud)
那里有一个错误,因为 Entry 只需要 (float x, float y)。显然,我可以将 double 转换为浮点数,但我需要 x 轴使日期不是浮点数。所以我做了更多的搜索,发现了很多关于它的 Github 问题,但我似乎无法理解那里的解决方案。大多数指向文档中的类似内容。我遇到的问题是我不明白这如何应用于 Entry(float x, float y) 问题。我找不到文档/解决方案所说的适用于 Entry() 的时间/地点。
因此,当我查看有关创建格式化程序然后对其进行设置的示例时,我不明白 entry.add(new Entry()) 内容的来源。该技术是否会取代它?我会以某种方式传递它吗?
作为参考,这是我在前面提到的初学者示例之后设计的完整方法。
public void updateUI(final ArrayList<ValueAndDateObject> …Run Code Online (Sandbox Code Playgroud) 因此,这里有两个类似的问题,但没有一个对我有可行的解决方案。
我正在使用从Github下载的Quickstart演示。今天下载。我没有在演示代码中进行任何更改。
我已经解决的一些常见错误(从我读到的内容):
我在Firebase控制台中创建了带有可下载的json文件(使用包名称创建)的项目。我提供了SHA1指纹。
电子邮件/密码登录方法已选中。
我已经更新并安装了Google Play服务和Google Repository(通过Android Studio SDK管理器)
在我的设备上,Google Play服务的版本为9.4.52
如果在Firebase控制台中启用“匿名登录”选项,则可以成功在演示应用程序上匿名登录。但是电子邮件/密码将不起作用。
编辑:不确定我是否做对了,但是我在Logcat中得到了这些
D/EmailPassword: createAccount:chris884@gmail.com
W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
W/ResourcesManager: Asset path '/system/framework/com.android.media.remotedisplay.jar' does not exist or contains no resources.
W/ResourcesManager: Asset path '/system/framework/com.android.location.provider.jar' does not exist or contains no resources.
D/EmailPassword: createUserWithEmail:onComplete:false
Run Code Online (Sandbox Code Playgroud)