我试图在android中构建一个看起来像这样的列表视图(忽略搜索栏):
输出.http://www.freeimagehosting.net/uploads/6394404c4d.png
iPhone有类似的选项称为部分索引:
我可以使用以下内容获取列表中的部分:http: //bartinger.at/listview-with-sectionsseparators/
现在我想构建索引(位于第一个图像右侧的东西)(索引是自定义的,可能只包含一个字母)
我不想通过以下方式这样做:
创建一个活动,左侧有一个列表视图,右侧有另一个文本视图(或可能是任何内容),然后跟踪正确的元素并更新列表.例如:http://hello-android.blogspot.com/2010/11/sideindex-for-android.html
我想自定义android本身的listview,以便列表视图在右边包含这样的索引.这样的事情.一个类extends ListActivity和类的一些或如何包含侧栏.(我将管理侧栏的编码工作).因此,每当另一个类扩展时MyCustomListActivity,它将具有列表以及侧边栏.
我的问题是如何在我的自定义类中包含扩展ListActivity的侧栏?或者有更好的方法来做到这一点?
我有一个使用web api调用的rails应用程序,rails app本身没有任何数据库或用户界面.每个api调用都需要为每个请求发送用户名和密码.
我想为rails app提供一种身份验证机制.我打算这样做:
现在我的问题是我在哪里存储密码?如果我使用会话我明显不能使用cookie存储,我可以使用session_store = :active_record_store但不确定它是否安全,我现在还没有任何数据库所以我为什么要创建一个仅用于会话?是否有其他机制可以在会话中存储密码?(明显安全的方式)
早期的铁路有:
但现在两者似乎都被删除了.还有其他解决方案吗?
答案备注:
我终于想到实现自定义内存存储但它似乎抛出stackoverflow错误.我从https://rails.lighthouseapp.com/projects/8994/tickets/1876-uninitialized-constant-actioncontrollersessionmemorystore获取了代码
require 'action_dispatch'
module ActionDispatch
module Session
class CustomMemoryStore < ActionDispatch::Session::AbstractStore
GLOBAL_HASH_TABLE = {} #:nodoc:
private
def get_session(env, sid)
sid ||= generate_sid
session = GLOBAL_HASH_TABLE[sid] || {}
session = AbstractStore::SessionHash.new(self, env).merge(session)
[sid, session]
end
def set_session(env, sid, session_data)
GLOBAL_HASH_TABLE[sid] = session_data
return true
end
end
end
end
Steptools3::Application.config.session_store :custom_memory_store, :key => '_some_xyz'
Run Code Online (Sandbox Code Playgroud) 我一直在使用苗条,突然发现它默认逃脱了一切.所以锚标签看起来像这样:
<a href="/users/lyann/followers">
<img class="user-image" src="http://adasdasdasd.cloudfront.net/users&# 47;2011/05/24/4asdasd/asdasd.jpg" />
Run Code Online (Sandbox Code Playgroud)
是否可以像这样转义href和src属性?还有其他影响吗?但是,所有浏览器似乎都没有问题.
我正在尝试从rails 2迁移到rails 3.
我面临一个奇怪的问题.
整个应用程序似乎没有使表名复数.
Mysql ::错误:表'r_database.country_data'不存在:
但是我的桌子上有country_datas作为名字.
应用程序在rails 2中完美运行.
我试图在片段内的线程中解析xml文件.
我的代码的部分片段是:
public void onCreate(Bundle savedInstanceState)
{
mAdapter = new ListItemNearbyStoresAdapter(getActivity().getApplicationContext(), mStoresByKey);
setListAdapter(mAdapter);
// Load the list of stores from hard coded xml
loadStoresByThread(getActivity().getApplicationContext());
}
private void loadStoresByThread(final Context ctx)
{
Thread t = new Thread()
{
public void run()
{
try
{
Log.d(TAG, "In the thread");
String[] files = ctx.getResources().getStringArray(R.array.storefiles);
// String[] files={"s1.xml"};
for (int i = 0; i < files.length; i++)
{
try
{
InputStream stream = getActivity().getAssets().open(files[i]);
NearbyItemDomFeedParser parser = new NearbyItemDomFeedParser(stream);
ArrayList<Store> stores = parser.parse();
Log.e("no …Run Code Online (Sandbox Code Playgroud) 我有类似这样的课
class MClass
{
private int mem1,mem2,mem3.......;
public int getmem1()
{
return mem1;
}
public int getmem2()
{
return mem2;
}
......
Run Code Online (Sandbox Code Playgroud)
现在我想要这样的东西:
public int getAttr(String attr)
{
if (attr=="mem1")
return mem1;
elseif (attr=="mem2")
return mem2;
.....
Run Code Online (Sandbox Code Playgroud)
如何为1000s attr实现getAttr?
请不要让我把mem作为数组...由于程序的其他部分而无法实现.
我正在学习大数据处理的火花.人们建议使用HiveContext结束SparkSqlContext.并建议使用dataframes而不是直接使用rdd.
Spark-sql对于查询规划器来说似乎是高度优化的,所以看起来使用spark-sql比通过scala(或python ...)使用Core api(RDD)更好.有什么我想念的吗?
我想在两个标签之间获取文本.
<b> foo</b>bar<br/> => bar
我试过用'<b>asdasd</b>qwe<br/>'.scan(/<b>[a-zA-Z0-9]*<\/b>(.*)<br\/>/)它,它给了我正确的结果.
但是当我尝试这个:
'<b>exclude</b>op1<br/>exclude 2<b>exclude</b>op2<br/>exclude 2<b>exclude</b>op3<br/>exclude 2'.scan(/<b>[a-zA-Z0-9]*<\/b>(.*)<br\/>/) { |ele|
puts ele
}
Run Code Online (Sandbox Code Playgroud)
它匹配第一个<b>标签和最后一个<br/>标签,并返回我期待一系列匹配的整个字符串
android ×3
apache-spark ×1
escaping ×1
function ×1
html ×1
html-parsing ×1
java ×1
listactivity ×1
pluralize ×1
regex ×1
ruby ×1
scala ×1
session ×1
xml ×1