我试图得到的高度和宽度ImageView的Fragment有以下ViewTreeObserver:
import android.view.ViewTreeObserver;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
private ImageView imageViewPicture;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_general_activity_add_recipe, container, false);
setHasOptionsMenu(true);
...
final ViewTreeObserver observer = imageViewPicture.getViewTreeObserver();
observer.addOnGlobalLayoutListener (new OnGlobalLayoutListener () {
@Override public void onGlobalLayout() {
observer.removeGlobalOnLayoutListener(this);
}
});
return view;
}
Run Code Online (Sandbox Code Playgroud)
运行此代码会导致以下异常:
10-12 23:45:26.145: E/AndroidRuntime(12592): FATAL EXCEPTION: main
10-12 23:45:26.145: E/AndroidRuntime(12592): java.lang.IllegalStateException: This ViewTreeObserver is not alive, call getViewTreeObserver() again
10-12 23:45:26.145: E/AndroidRuntime(12592): at android.view.ViewTreeObserver.checkIsAlive(ViewTreeObserver.java:509)
10-12 23:45:26.145: E/AndroidRuntime(12592): …Run Code Online (Sandbox Code Playgroud) 我想从List中动态创建DropDownLists,它提供SelectList和一个保存选择的字段.
public class ViewModel
{
public List<Material_Select> materialSelect { get; set; }
}
public class Material_Select
{
public SelectList selectList { get; set; }
public int MaterialId { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
在视图中,我想循环遍历materialSelect List并动态创建DropDownLists.
像这样的东西:
int count = 0;
foreach (var item in Model.materialSelect)
{
count++;
<div class="editor-label">
@Html.LabelFor(model => model.materialSelect)
</div>
<div class="editor-field">
@Html.DropDownListFor(item.MaterialId, item.selectList)
</div>
}
Run Code Online (Sandbox Code Playgroud)
在HttpPost ActionResult我需要获取选定的值.有谁知道如何解决这个问题?
我坚持使用自定义iprincpal和iidentity对象的实现.我现在花了一天时间来搜索如何实现这些权利并用更多信息扩展它.
我想@Context.User.Identity.Name用自定义变量(如全名或其他)扩展信息.
编辑:现在,我得到以下代码,但如果我尝试阅读@((CustomPrincipal)Context.User.Identity).Nachname我收到一个System.Web.Security.FormsIdentity无法输入的错误CustomPrincipal.
有任何想法吗?
public class CustomPrincipal : GenericPrincipal
{
public CustomPrincipal(IIdentity identity, String[] roles) : base(identity, roles){
}
public String Vorname { get; set; }
public String Nachname { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
AccountModel:
public class FormsAuthenticationService : IFormsAuthenticationService
{
public void SignIn(string userName, bool createPersistentCookie)
{
if (String.IsNullOrEmpty(userName)) throw new ArgumentException("Der Wert darf nicht NULL oder leer sein.", "userName");
// Grab user information to insert
KIMembershipUser membershipUser = (KIMembershipUser)Membership.GetUser(userName); …Run Code Online (Sandbox Code Playgroud) 我想在ActionBar中使用Fragments.不幸的是,它看起来真的很复杂.我的片段有Textviews,我希望能够通过我的活动与他们进行交流.在我开始使用Fragments之前,我可以使用它来访问它们
private EditText editText = (EditText) findViewById(R.id.editTextName);
Run Code Online (Sandbox Code Playgroud)
因此,当用户单击"保存"时,我能够收到editText值.我应该怎样做片段式的方式?
活动:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_recipe);
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
getSupportActionBar().setDisplayOptions(0, com.actionbarsherlock.app.ActionBar.DISPLAY_SHOW_HOME | com.actionbarsherlock.app.ActionBar.DISPLAY_USE_LOGO | com.actionbarsherlock.app.ActionBar.DISPLAY_SHOW_TITLE);
ActionBar.Tab newTab0 = getSupportActionBar()
.newTab()
.setText(R.string.fragment_general)
.setTabListener(
new MyTabListener<GeneralFragment>(this, "general",
GeneralFragment.class));
getSupportActionBar().addTab(newTab0);
}
public static class MyTabListener<T extends Fragment> implements
TabListener {
private Fragment mFragment;
private final Activity mActivity;
private final String mTag;
private final Class<T> mClass;
/**
* * Constructor used each time a new tab is created. * * @param
* activity * The …Run Code Online (Sandbox Code Playgroud) 我以为Html.HiddenFor可以使用像Html.DisplayFor或的模板Html.EditorFor.不幸的是,该方法不接受TemplateName其他方法.
我知道,解决方法是使用具有HiddenFors的DisplayFor/EditorFor模板.但我想了解如何扩展该Html.HiddenFor方法.任何人?
问候
我正在使用Web应用程序来托管在Silverlight Web应用程序中使用的Webservices(svc).过了一会儿,我向我的服务添加了一些新东西,现在我尝试在Silverlight应用程序项目中刷新我的代理类.
不幸的是,Visual Studio现在生成新的类名.在我这之前:
public SilverlightApplication.ServiceReferenceDoc.Document Document
Run Code Online (Sandbox Code Playgroud)
但现在我得到了一个不同的班级名称(名字后面的第一名)
SilverlightApplication.ServiceReferenceDoc.Document1 Document
Run Code Online (Sandbox Code Playgroud)
这真的很糟糕,因为我的Silverlight项目有很多web服务,而且这些服务有很多使用这些代理类的代码.
到目前为止,我发现它生成代理类2次.
一些想法为什么要重命名?我已经尝试了VS2015,VS2013,我也删除了完整的参考并再次添加,但它是一样的.
我正在尝试从文档库中的文件夹中的子文件夹下载txt文件.
我正在使用camlQuery来实现这一目标.不幸的是,我没有得到txt文件的内容.它有0个字节.
public void SaveFolderFiles(string fileName, string libraryName, ClientOM.ClientContext clientContext)
{
ClientOM.List sharedDocumentsList = clientContext.Web.Lists.GetByTitle(libraryName);
ClientOM.CamlQuery camlQuery = new ClientOM.CamlQuery();
camlQuery.FolderServerRelativeUrl = "/Site/Folder/Folder2010/";
camlQuery.ViewXml =
@"<View>
<Query>
<Where>
<Eq>
<FieldRef Name='FileLeafRef'/>
<Value Type='Text'>" + fileName + @"</Value>
</Eq>
</Where>
<RowLimit>1</RowLimit>
</Query>
</View>";
ClientOM.ListItemCollection listItems = sharedDocumentsList.GetItems(camlQuery);
clientContext.Load(sharedDocumentsList);
clientContext.Load(listItems);
clientContext.ExecuteQuery();
if (listItems.Count == 1)
{
ClientOM.ListItem item = listItems[0];
Console.WriteLine("FileLeafRef: {0}", item["FileLeafRef"]);
Console.WriteLine("FileDirRef: {0}", item["FileDirRef"]);
Console.WriteLine("FileRef: {0}", item["FileRef"]);
Console.WriteLine("File Type: {0}", item["File_x0020_Type"]);
ClientOM.FileInformation fileInformation = ClientOM.File.OpenBinaryDirect(clientContext, (string)item["FileRef"]);
using (MemoryStream memoryStream = …Run Code Online (Sandbox Code Playgroud) 我正在尝试将公共属性的DisplayFormat设置为当前的cultureinfo日期时间格式.该类将用于Silverlight Datagrid.
[DisplayFormat(DataFormatString=CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern.ToString())]
public DateTime createDate { get; set; }
Run Code Online (Sandbox Code Playgroud)
它说,只有参数只能是常数和typeof参数...
有任何想法吗?
更新,我尝试了Lukazoid解决方案,但Silverlight数据网格忽略了数据注释.由于本地化,datagrid列在代码隐藏中添加.
该列如下所示:
DataGridTextColumn tcCreateDate = new DataGridTextColumn();
tcCreateDate.Header = SilverlightApplication.Resources.ContentGrid.dgCreateDate;
tcCreateDate.Binding = new Binding("createDate");
Run Code Online (Sandbox Code Playgroud) 我正在尝试在 PowerShell 中将字符串转换为枚举值,但在任何地方都找不到它...
我得到一个 JSON 结果,我只想使用定义为字符串的 Healthstate。
enum HealthState
{
Invalid = 0
Ok = 1
Warning = 2
Error = 3
Unknown = 65535
}
$jsonResult = "Ok"
$HealthStateResultEnum = [Enum]::ToObject([HealthState], $jsonResult)
Run Code Online (Sandbox Code Playgroud)
提前致谢。
我试图通过webconfig为应用程序文件夹"/"拒绝匿名用户访问文件和文件夹,并允许访问特殊的控制器路径("共享","Verfolgung").
"共享"路径的配置有效,但访问"Verfolgung"需要验证.
也许你告诉我什么是错的?
问候,漂浮
web.config的一部分:
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" path="/" protection="All" timeout="2880" />
</authentication>
<location path="Verfolgung">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
<location path="Shared">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
Run Code Online (Sandbox Code Playgroud) c# ×6
android ×2
asp.net-mvc ×2
android-view ×1
caml ×1
enums ×1
html-select ×1
iidentity ×1
iprincipal ×1
localization ×1
powershell ×1
silverlight ×1
svc ×1
web-config ×1
web-services ×1