有点问题.我想创建一个Android列表视图活动,列表中的所有项目都具有固定的高度.
所以,我的项目布局(thread_item.xml)如下所示:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="300dip"
>
<TextView android:id="@+id/thread_item_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="[dummy]"
android:textSize="20dip"
android:textStyle="bold"
/>
<ImageView android:id="@+id/thread_first_image"
android:layout_below="@id/thread_item_title"
android:scaleType="centerInside"
android:maxWidth="100dip"
android:maxHeight="100dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true" />
<TextView
android:id="@+id/thread_item_preview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@id/thread_first_image"
android:text="[dummy]"
android:textSize="15dip">
</TextView>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我将根元素的layout_height设置为300dip,并期望所有项目具有相同的高度,但它们没有.当我运行应用程序时,它看起来像具有wrap_content值的高度.
此外,活动本身如下:
public class ThreadListActivity extends ListActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/*
Code to get items from the storage.
*/
setListAdapter(new ThreadItemAdapter(this, R.layout.thread_item, itemsArray)));
getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
/*Start …Run Code Online (Sandbox Code Playgroud) 我正在为XCode 4中的iOS编写一个应用程序,偶然发现了#import语句的问题.
我的所有源文件都组织在文件夹中,每个文件夹都映射到XCode中的组或子组.考虑以下:
ProjectFolder
-SubFolderA
--FileA.h
-SubFolderB
--FileB.m
通常,如果我想将FileA导入FileB,我会写#import "FileA.h",并且它可以完美地工作.但有时我必须写相对路径,比如#import "../SubFolderA/FileA.h".我该怎么办才能始终只写出文件的名称?
这种行为似乎对我不确定.
PS:我不想把所有这些混乱放在一个根文件夹中.
PS#2:是的,我知道'文件夹'与'组'的区别.我在项目的早期阶段创建了文件夹,将它们从Finder拖到XCode并将它们映射到组.一切正常 - 我只能使用文件名导入标题.
我正在使用ASP.NET MVC Framework 3和Forms Authentication.我知道,如何检查服务器端,如果用户被授权进行某些操作([Authorize]我),我知道如何在一个操作或一个视图(与User.Identity.IsAuthenticated'User'的其他成员)中检查这一点.
我正在尝试做的是定义一些JavaScript代码,这些代码将以不同的方式执行,具体取决于用户是否获得授权.
在页面上考虑这样的脚本:
<script>
function Foo(){
if(userAuthorized)
alert("You\'re in the system");
} else {
alert("You\'re not authorized");
}
<script>
Run Code Online (Sandbox Code Playgroud)
功能Foo()由某些事件触发,比如点击.而且我希望能够在客户端检查用户是否获得授权.
我提出的最佳解决方案是在视图中实际渲染全局变量.像这样:
@if(User.Identity.IsAuthenticated)
{
<script>
var userAuthorized = true;
</script>
}
else
{
<script>
var userAuthorized = false;
</script>
}
Run Code Online (Sandbox Code Playgroud)
但在我看来,这似乎不是一个好方法.还有其他方法吗?提前致谢.
PS:这是一个可用性问题,当然我正在对服务器进行必要的检查.
javascript authentication authorization forms-authentication asp.net-mvc-3
我目前正在使用最新的Visual Studio 2012运行最新的Xamarin.Android试用版安装.
在visual studio中打开.axml文件时,我可以看到一个可视化设计器,并且可以正常使用它,当我切换到"Source"选项卡时,我可以看到一个完美的布局xml,语法突出显示等等.
问题是,自动完成只能建议XML注释和CDATA元素,没有别的.
有没有办法在Visual Studio中转换Android感知自动完成?我记得Xamarin Studio能够自动完成布局,但是当打开在Visual Studio中编辑的解决方案时,Xamarin Studio也无法自动建议.
有任何想法吗?提前致谢.
编辑:切换到付费版本,问题仍然存在于Xamarin和Visual Studios.
我正在编写 chrome 扩展程序并有一个问题。
我的扩展中有一些 .html 页面,让它成为“popup.html”。我将内容脚本注入某个页面,该脚本在新选项卡中打开一个“popup.html”,其中包含“var p = window.open(chrome.extension.getURL('/popup.html'), "popup" )',它完美地工作。接下来,我需要将一些数据传递给这个窗口,但我不知道如何以简单的方式做到这一点。
出于某种原因,我无法从内容脚本中调用子窗口的函数
var p = window.open(chrome.extension.getURL('/popup.html'), "popup");
p.foo(data);
Run Code Online (Sandbox Code Playgroud)
在控制台中,我看到Uncaught TypeError: Cannot call method 'foo' of undefined message。
我无法在查询字符串中传递数据,因为数据实在是太大了。
有没有一种优雅而简单的方法将数据传递给这种窗口?我考虑过消息传递,但是如何使用背景页面有效地获取新打开的窗口的标签 ID?
非常感谢。
UPD:我尝试反转逻辑并使用 'window.opener.foo()' 从父窗口获取数据,但在新打开的选项卡中window.opener返回null。
这个问题被问了很多次,但以前的答案对我没有帮助,或者我做错了什么.
无论如何,我有一个Visual Studio 2012解决方案,主要由.NET项目组成,但是有几个VC++项目,每当我打开解决方案时都无法加载."解决方案"输出中每个VC++项目的错误是:
D:\ folder\SomeProject.vcxproj:错误:无法读取项目文件"SomeProject.vcxproj".D:\ folder\SomeProject.vcxproj(102,3):找不到导入的项目"C:\ Microsoft.Cpp.props".确认声明中的路径是否正确,以及该文件是否存在于磁盘上.
项目本身使用$(VCTargetsPath)宏来解析文件夹,但由于某种原因它失败了.我尝试了几种解决方案,包括更新注册表和设置环境变量.唯一值得注意的变化是我将VCTargetsPath环境变量设置为有效文件夹,就像C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110我的情况一样.重新加载解决方案后,我得到以下输出:
D:\ folder\SomeProject.vcxproj:错误:无法读取项目文件"SomeProject.vcxproj".D:\ folder\SomeProject.vcxproj(102,3):找不到导入的项目" D:\ Microsoft.Cpp.props".确认声明中的路径是否正确,以及该文件是否存在于磁盘上.
我尝试从控制面板运行VS修复,但它没有帮助.我目前无法重新安装Visual Studio,因为我无法访问公司使用的安装文件.我想出的唯一可行的解决方法是从CLI构建MSBuild并在那里设置VCTargetsPath,如下所示:
$TargetsPath = 'C:\Program%20Files%20(x86)\MSBuild\Microsoft.Cpp\v4.0\v110\'
msbuild /v:$Verbosity /m /t:$Target /P:Configuration=$Configuration /P:VCTargetsPath=$TargetsPath /P:TreatWarningsAsErrors=false "$($Solution.FullName)"
Run Code Online (Sandbox Code Playgroud)
并且解决方案构建得很好.但是,我确实需要正确加载到VS解决方案中,因此这种解决方法只能解决我的一些问题.
最后,我想,我的问题是如何VCTargetsPath在Visual Studio 2012环境中设置或覆盖宏?或者如何找出这个宏值的来源?我正在使用Visual Studio 2012 - 版本11.0 Update 5.
我正在开发一个 Xamarin.Forms 应用程序,它可以在所有 Android 版本(包括 11)上正常运行。
但是,我被要求将该应用程序定位到 Android 12。所以我将所有NuGet包更新到最新,安装了JDK11,在Projects > Android > Locations中设置它。我在 Android 项目设置中将“编译方式”SDK 更改为Android 12.0 (S)“目标 Android 版本” 。Android 12.0
该应用程序编译良好,并在 Android 11 模拟器上正常运行。但是,一旦我部署到 Android 12 模拟器,Visual Studio 就会显示“无法附加调试器”错误,并且应用程序在本机启动后立即崩溃。Logcat 有这个显示:
2021-12-01 17:41:51.888 17289-17289/com.my.project W/monodroid-gc: GREF GC Threshold: 46080
2021-12-01 17:41:53.132 17289-17289/com.my.project W/com.my.project: Attempt to remove non-JNI local reference, dumping thread
2021-12-01 17:41:54.382 17289-17321/com.my.project D/libEGL: loaded /vendor/lib64/egl/libEGL_emulation.so
2021-12-01 17:41:54.392 17289-17321/com.my.project D/libEGL: loaded /vendor/lib64/egl/libGLESv1_CM_emulation.so
2021-12-01 17:41:54.400 17289-17321/com.my.project D/libEGL: loaded /vendor/lib64/egl/libGLESv2_emulation.so
2021-12-01 17:41:58.663 17289-17289/com.my.project W/com.my.project: Accessing hidden method …Run Code Online (Sandbox Code Playgroud) android ×2
xamarin ×2
autocomplete ×1
c++ ×1
directory ×1
import ×1
javascript ×1
msbuild ×1
xcode ×1