所以我之前遇到过这个问题,我自然就在这里寻求帮助.Luksprog的答案很棒,因为我不知道ListView和GridView如何通过回收视图优化自身.因此,根据他的建议,我能够改变将Grid添加到GridView的方式.问题是现在我有一些没有意义的事情.这是getView我的BaseAdapter:
public View getView(int position, View convertView, ViewGroup parent) {
if(convertView == null) {
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
convertView = inflater.inflate(R.layout.day_view_item, parent, false);
}
Log.d("DayViewActivity", "Position is: "+position);
((TextView)convertView.findViewById(R.id.day_hour_side)).setText(array[position]);
LinearLayout layout = (LinearLayout)convertView.findViewById(R.id.day_event_layout);
//layout.addView(new EventFrame(parent.getContext()));
TextView create = new TextView(DayViewActivity.this);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0, (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 62, getResources().getDisplayMetrics()), 1.0f);
params.topMargin = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, getResources().getDisplayMetrics());
params.bottomMargin = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, getResources().getDisplayMetrics());
create.setLayoutParams(params);
create.setBackgroundColor(Color.BLUE);
create.setText("Test");
//the following is my original LinearLayout.LayoutParams for correctly setting the TextView Height …Run Code Online (Sandbox Code Playgroud) 文档dismiss()从Dialog类中说出这个方法:
关闭此对话框,将其从屏幕上删除.可以从任何线程安全地调用此方法.请注意,在关闭对话框时,不应该覆盖此方法以进行清理,而是在其中实现
onStop().
在我的代码中,我所做的只是打电话getDialog().dismiss()来解雇它.但我没有做任何其他事情,甚至没有使用onStop().所以我问到究竟如何正确解雇a DialogFragment以避免任何内存泄漏等.
我一直在寻找整个系统,但我找不到它.当我回显$ PATH时,我得到了我添加的东西,加上默认路径.我没有.profile,我确实有.bashrc,但默认路径不在那里.我正在寻找它只是为了知道它的位置,因为所有的教程都解释了它的.profile ......但是如果你没有它呢?它在哪里?有人有什么想法吗?
我正在制作一个日历,我需要一个网格.问题是边界,或者更确切地说是每个网格之间的空间,这是我用来模拟网格的,是1 dp.但它相当厚实.我正在寻找具有边框的其他日历应用程序,它们非常薄.即使我使用一个drawable形状并使其成为1dp,它仍然具有该厚度.我尝试使用.5,但这似乎不起作用.这不可能吗?
所以我有我的MainDisplayActivity两个Activity和LoaderManager.LoaderCallbacks<Cursor>.在这里,我有一个A ListView,我填写了我使用ContentProvider从我的数据库获得的议程信息.我也有GridView一个日历.我点击一个单元格时设置了它,在点击的那一天更新议程.我的问题是,当重用我在onCreate()setOnItemClickListener()内部创建的Loader时,它不会使用我正在创建的新游标刷新信息.我可以用另一个ID创建一个新的Loader,它可以运行一次,但是一旦我点击另一天,它就会停止刷新.问题在于光标.如何从Loader刷新游标,这样我就不必继续创建新的Loader?提前致谢!
初始调用在My MainDisplayActivity类中的onCreate()中创建Loader :
makeProviderBundle(new String[] {"_id, event_name, start_date, start_time, end_date, end_time, location"},
"date(?) >= start_date and date(?) <= end_date", new String[]{getChosenDate(), getChosenDate()}, null);
getLoaderManager().initLoader(0, myBundle, MainDisplayActivity.this);
list.setAdapter(agendaAdapter);
Run Code Online (Sandbox Code Playgroud)
这些是被重写的方法 LoaderCallbacks<Cursor>
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
Uri baseUri = SmartCalProvider.CONTENT_URI;
return new CursorLoader(this, baseUri, args.getStringArray("projection"),
args.getString("selection"), args.getStringArray("selectionArgs"), args.getBoolean("sortOrder") ? args.getString("sortOrder") : null );
}
@Override
public void onLoadFinished(Loader<Cursor> arg0, Cursor arg1) {
agendaAdapter.swapCursor(arg1);
}
@Override …Run Code Online (Sandbox Code Playgroud) debugging android android-contentprovider android-loadermanager android-cursorloader
我正在浏览一些代码,我意识到我实际上并不知道如何使用连接CursorLoader和LoaderManager组合CursorAdapter.这是我困惑的部分.
agendaAdapter = new MyAgendaAdapter(this, null);
makeProviderBundle(new String[] {"_id", "event_name", "start_date", "start_time",
"end_date", "end_time", "location"}, "date(?) >= start_date and date(?) <= end_date",
new String[]{getChosenDate(), getChosenDate()}, null);
getLoaderManager().initLoader(0, myBundle, MainDisplayActivity.this);
list.setAdapter(agendaAdapter);
Run Code Online (Sandbox Code Playgroud)
那么query()我的自定义方法如何ContentProvider将其发送到特定的方法CursorAdapter呢?我只是没有看到连接.我理解其他一切,但这个问题是什么.哦,我应该提一下,代码工作正常.
android android-contentprovider android-loadermanager android-cursorloader
我一直在尝试解压缩以下文件:
sudo wget http://download.oracle.com/otn-pub/java/jdk/7u21-b11/jdk-7u21-linux-x64.tar.gz
Run Code Online (Sandbox Code Playgroud)
以下内容:
sudo tar zxvf jdk-7u21-linux-x64.tar.gz -C /usr/lib/jvm/
Run Code Online (Sandbox Code Playgroud)
我收到了这个错误
gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now
Run Code Online (Sandbox Code Playgroud)
我正在使用Amazon Linux实例.默认安装jre而不是jdk,我需要能够运行jboss.我会安装jdk使用yum,但不幸的是它似乎不可能.我遇到的问题是,如果我从我能够辨别出来的所有事情中做出正确的事情,那么为什么它不起作用是没有意义的.我已经下载了两个不同的版本,以确保它不仅仅是损坏的文件.任何帮助搞清楚这一点将不胜感激!
我有点认为它是一个字符串,所以我将它作为一个字符串进行比较,但毫不奇怪它失败了.我相信它在Mysql中是如何工作的.我可能错了,因为我有一段时间没有参与其中.在任何一种情况下,如何检查SQLite中的日期是否相等?我将在WHERE子句中使用它.
SELECT a._id, b._id, b.start_date,a.event_name, b.start_time,
b.end_date, b.end_time, b.location FROM events_info b INNER JOIN events a ON
a._id=b.event_id WHERE b.start_time = '6:00';
Run Code Online (Sandbox Code Playgroud)
(增加了空间,使其更容易看)
谷歌文档指出不使用第CursorAdapters一个构造函数,
CursorAdapter(Context context, Cursor c)
Run Code Online (Sandbox Code Playgroud)
只有两个选项,
CursorAdapter(Context context, Cursor c, boolean autoRequery)
Run Code Online (Sandbox Code Playgroud)
这说
允许控制自动重新查询的构造函数.建议您不要使用它,而是使用CursorAdapter(Context,Cursor,int).使用此构造函数时,将始终设置FLAG_REGISTER_CONTENT_OBSERVER
和
CursorAdapter(Context context, Cursor c, int flags)`
Run Code Online (Sandbox Code Playgroud)
这说它是推荐的构造函数.
问题是这里只有两个标志用于最后一个构造函数,FLAG_AUTO_REQUERY(int 1)和FLAG_REGISTER_CONTENT_OBSERVER(int 2).使用FLAG_AUTO_REQUERY没有意义,因为我现在使用CursorLoader在后台管理它并更新它.有FLAG_REGISTER_CONTENT_OBSERVER,它表示使用时不需要CursorLoader.
现在我问,我通过什么整数CursorAdapter(Context context, Cursor c, int flags)才能使它与我的工作正常CursorAdapter?让我担心的是如何正确管理旧光标.我不确定这样做的正确方法.
如果我使用FLAG_REGISTER_CONTENT_OBSERVER,那么我必须做一些事情onContentChanged(),但swapCursor()在我使用时LoaderManager,由于光标未关闭,我可以做adapter.swapCursor(cursor).close().但会与冲突onContentChanged()的CursorAdapter?目标是不会导致任何内存泄漏并且效率很高.
android android-contentprovider android-loadermanager android-cursorloader android-cursoradapter
我正在阅读文档,但我仍然不太确定.它说要使用getContentResolver(),但那时确实没有使用CursorLoader.那么有办法实现CursorLoader吗?我知道如何做到这一点query().步骤非常相似吗?即使只是一个可以解释这一点的链接也会有所帮助.
请注意,请勿将我链接到Google文档,因为他们没有使用insert()ContentProvider使用方法的示例CursorLoader.
提前致谢!!
编辑:我应该提到我与此混淆的原因是因为调用一个新的CursorLoader自动调用ContentProviders query()方法.但是如何才能为插入做同样的事情呢?
android android-contentresolver android-contentprovider android-loadermanager android-cursorloader