我需要以编程方式使用GPS获取当前位置.我怎样才能实现它?
我有一个android布局,其中包含scrollView许多元素.在scrollView我的底部有一个listView然后由适配器填充.
,我遇到的问题是,Android是不包括listView从scrollView作为scrollView已经具有滚动能够功能.我希望listView只要内容和主滚动视图是可滚动的.
我怎样才能实现这种行为?
这是我的主要布局:
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:fillViewport="true"
android:gravity="top" >
<LinearLayout
android:id="@+id/foodItemActvity_linearLayout_fragments"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
然后我以编程方式将我的组件添加到具有id:的linearlayour foodItemActvity_linearLayout_fragments.下面是加载到该线性布局中的一个视图.这是给我卷轴问题的那个.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/fragment_dds_review_textView_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Reviews:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<ListView
android:id="@+id/fragment_dds_review_listView"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</ListView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我的适配器然后填写此列表视图.
当我点击主滚动视图时,这是来自android层次结构查看器的图像:
如您所见,它排除了评论listView.
我应该能够向下滚动页面并查看8条评论,但它只向我展示了那些3,我可以滚动查看评论的小部分.我想要一个全局页面滚动
我有一个主要的活动,当我点击一个按钮,开始一个新的活动,我使用以下代码来做到这一点:
Intent intent = new Intent(this, SettingsActivity.class);
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
上面的代码是从主要活动运行的.
现在,在我的主要活动调用的新活动中,我有一个后退按钮.当我点击这个后退按钮时,我希望我的新活动关闭,它必须返回到原始的主要活动.
我已经尝试过调用super.finish()而且只是finish() (来自新活动),但这会关闭我的整个应用程序(包括我的主要活动).
如何关闭当前焦点的活动,然后返回主活动?
EDITED
我的手机的后退按钮也关闭了我的整个应用程序的事实,让我认为我已经错误地启动了第二个活动?
好的,我一直在寻找,
我创建了一个设置活动,它使用相同的清单代码和相同的代码来启动活动.
对于按下后退按钮时的设置活动,它将返回主活动.
通过上面在主要问题中提到的活动,它只是退出我的整个应用程序.
所以问题似乎不是完成活动的代码,而是活动本身.
我有这个:
<li><a href="/Users/Index)" class="elements"><span>Clients</span></a></li>
Run Code Online (Sandbox Code Playgroud)
哪个工作正常.但是,如果我已经在这个页面或控制器上,例如/Users/Details我单击此链接,它会重定向到我/Users/Index.
href无论我目前在网站上的位置如何,我怎样才能获得正确的路径?
在C#2.0中处理XML文档,XSD等的最佳方法是什么?
使用哪些类等.解析和制作XML文档等的最佳实践是什么?
编辑:.Net 3.5建议也欢迎.
我复制了以前的项目并将其重命名.一旦我成功重命名所有名称空间并正确构建.运行应用程序时出现以下错误:
The following errors occurred while attempting to load the app.
- The OwinStartup attribute discovered in assembly 'User Manager Interface' referencing startup type 'User_Manager_Interface.Startup' conflicts with the attribute in assembly 'Service Monitor Web Interface' referencing startup type 'Service_Monitor_Web_Interface.Startup' because they have the same FriendlyName ''. Remove or rename one of the attributes, or reference the desired type directly.
To disable OWIN startup discovery, add the appSetting owin:AutomaticAppStartup with a value of "false" in your web.config.
To specify the OWIN …Run Code Online (Sandbox Code Playgroud) 我整个下午都试图在网上爬行,试图在动作控制器中接收一个JSON对象.
这样做的正确和/或更简单的方法是什么?
我尝试过以下方法:1:
//Post/ Roles/AddUser
[HttpPost]
public ActionResult AddUser(String model)
{
if(model != null)
{
return Json("Success");
}else
{
return Json("An Error Has occoured");
}
}
Run Code Online (Sandbox Code Playgroud)
这给了我输入的空值.
2:
//Post/ Roles/AddUser
[HttpPost]
public ActionResult AddUser(IDictionary<string, object> model)
{
if(model != null)
{
return Json("Success");
}else
{
return Json("An Error Has occoured");
}
}
Run Code Online (Sandbox Code Playgroud)
这给了我jquery方面的500错误,试图发布到它?(意思是它没有正确绑定).
这是我的jQuery代码:
<script>
function submitForm() {
var usersRoles = new Array;
jQuery("#dualSelectRoles2 option").each(function () {
usersRoles.push(jQuery(this).val());
});
console.log(usersRoles);
jQuery.ajax({
type: "POST",
url: "@Url.Action("AddUser")",
contentType: "application/json; charset=utf-8",
dataType: "json", …Run Code Online (Sandbox Code Playgroud) 我想JSON从Http get响应中获取一个对象:
这是我目前的Http获取代码:
protected String doInBackground(String... params) {
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet(params[0]);
HttpResponse response;
String result = null;
try {
response = client.execute(request);
HttpEntity entity = response.getEntity();
if (entity != null) {
// A Simple JSON Response Read
InputStream instream = entity.getContent();
result = convertStreamToString(instream);
// now you have the string representation of the HTML request
System.out.println("RESPONSE: " + result);
instream.close();
if (response.getStatusLine().getStatusCode() == 200) {
netState.setLogginDone(true);
}
}
// Headers
org.apache.http.Header[] …Run Code Online (Sandbox Code Playgroud) 我一直在读JWT.
但从我读到的内容来看,它不是一种身份验证机制,而更像是身份验证机制中的一个关键组件.
我目前已经实现了一个有效的解决方案,但它只是试用JWT并看看它是如何工作的.但我现在所追求的是如何利用它.根据我的经验,它基本上只是一种加密机制,可以为您提供唯一的加密密钥.您还可以将信息放在此令牌内.
我希望在ASP.NET web api 2上实现它以供移动应用程序使用.
所以第1步:
现在这只是我对它的理解,看起来我可能走在完全错误的道路上.
是JWT的理想选择,以便您不必在每次请求时进行身份验证吗?我只是验证用户凭证一次(在初始登录时),然后服务器可以简单地使用JWT,而不必在数据库中查找用户pw和用户?
我只想使用JWT来识别用户身份.然后,在我对它们进行身份验证后,我将授权.据我所知,新的MVC和身份验证和授权存在很大的混淆.
那么我的问题归结为什么.
如何使用JWT安全有效地实施身份验证机制?我不想只是咳嗽似乎有用的东西而且没有任何关于安全隐患的想法.我确信存在一些可能设计出符合我要求的安全机制的源.
我的要求是:
谢谢
我有以下代码生成片段,但只有当我将它们添加到我的XML文件中存在的线性布局时.
LinearLayout fragmentsLayout = (LinearLayout) findViewById(R.id.foodItemActvity_linearLayout_fragments);
FragmentManager fragMan = getFragmentManager();
FragmentTransaction fragTransaction = fragMan.beginTransaction();
Fragment myFrag= new ImageFragment();
fragTransaction.add(R.id.foodItemActvity_linearLayout_fragments, myFrag , "fragment" + fragCount);
fragTransaction.commit();
Run Code Online (Sandbox Code Playgroud)
现在,如果我想将该片段添加到XML文件中尚不存在的线性布局,例如
LinearLayout rowLayout = new LinearLayout();
Run Code Online (Sandbox Code Playgroud)
第2部分:
Fragment frag1 = generateAppropriateFragment(type1);
Fragment frag2 = generateAppropriateFragment(type2);
LinearLayout fragmentsLayout = (LinearLayout) findViewById(R.id.foodItemActvity_linearLayout_fragments);
LinearLayout rowLayout = new LinearLayout(this);
rowLayout.setId(12345); // add counter to end
fragmentsLayout.addView(rowLayout);
getFragmentManager().beginTransaction().add(rowLayout.getId(), frag1, "fragment_grandchild" + fragCount).commit();
fragCount++;
getFragmentManager().beginTransaction().add(rowLayout.getId(), frag2, "fragment_grandchild" + fragCount).commit();
fragCount++;
Run Code Online (Sandbox Code Playgroud)