我有一个TabbedPage,其中包含一些ContentPage由组成,其中ContentView一些具有ListView。
将ListView包含一个被分组 ItemsSource为代表的自定义模型类:
public class DataGroup: List<DataGroupItem>
{
public string HeaderText { get; set; }
public string ShortName { get; set; }
public string SubTitle { get; set; }
public DataGroup(string headerText, string shortName)
{
HeaderText= headerText;
ShortName= shortName;
}
}
Run Code Online (Sandbox Code Playgroud)
XAML代码(它也具有ItemTemplate):
<ListView x:Name="listView"
Grid.Row="0"
GroupDisplayBinding="{Binding HeaderText}"
GroupShortNameBinding="{Binding ShortName}"
HasUnevenRows="True"
IsGroupingEnabled="True"
ItemsSource="{Binding DataGroups}"
SeparatorColor="Black"
SeparatorVisibility="Default">
...
</ListView>
Run Code Online (Sandbox Code Playgroud)
更改实际选项卡时,需要ListView将滚动到某个组。
我使用以下代码:
ObservableCollection<DataGroup> dataGroups
= this.listView.ItemsSource as ObservableCollection<DataGroup>; …Run Code Online (Sandbox Code Playgroud) 我有以下代码用于将Func基于过滤器的数据转换为Entity Framework Core 2.2Expression并过滤数据:
public async Task<TType> GetDataAsync<TType>(Func<TType, bool> filtering = null) where TType : class
{
Expression<Func<TType, bool>> filteringExpression = (type) => filtering(type);
if (filtering != null)
//return await myContext.Set<TType>().FirstOrDefaultAsync(filteringExpression);
return await myContext.Set<TType>().Where(filteringExpression ).FirstOrDefaultAsync();
return await myContext.Set<TType>().FirstOrDefaultAsync();
}
Run Code Online (Sandbox Code Playgroud)
这就是我的使用方式:
public async Task<DataLog> GetDataLogByID(Guid dataLogID) => await GetDataAsync<DataLog>(dataLog => dataLog.ID == dataLogID);
Run Code Online (Sandbox Code Playgroud)
(不)幸运的是,当我升级到Entity Framework Core 3.0时,代码抛出了一个错误InvalidOperationException,因为表达式无法转换为 SQL 查询(尽管它仅过滤与数据库列匹配的属性):
System.InvalidOperationException:“无法翻译 LINQ 表达式 'Where( source: DbSet, predicate: (f) => Invoke(__filtering_0, f[DataLog]) )”。以可翻译的形式重写查询,或者通过插入对 AsEnumerable()、AsAsyncEnumerable()、ToList() …
我只是尝试使用ActiveAndroid.从下面的教程在这里,我设置的一切.我添加了清单条目:
应用程序android:name ="com.activeandroid.app.Application"...
Run Code Online (Sandbox Code Playgroud)meta-data android:name="AA_DB_NAME" android:value="MyDb.db" meta-data android:name="AA_DB_VERSION" android:value="1"
并创建了我的模型类:
package com.mycomp.Model;
import org.joda.time.LocalDate;
import org.odata4j.core.Guid;
import com.activeandroid.Model;
import com.activeandroid.annotation.Column;
import com.activeandroid.annotation.Table;
@Table(name = "Table1")
public class Table1 extends Model
{
@Column(name = "Custom_ID")
public Guid Custom_ID;
@Column(name = "Name")
public String Name;
@Column(name = "Usr_type")
public int Usr_type;
@Column(name = "BDate")
public LocalDate BDate;
public MyEnum UserGroup;
public Table1()
{
super();
}
public Table1(String name, LocalDate date, Guid custom_id,
MyEnum userGroup)
{
super();
Name = name;
BDate …Run Code Online (Sandbox Code Playgroud) 在开发计算机上,当我使用InstallUtil时没有错误,该服务已成功安装.
我打算将它安装在另一台计算机上(安装了.Net 4.0),因此我将以下文件复制到目标目录:
在管理员模式下运行util后,我收到以下异常:
未处理的异常:System.TypeLoadException:无法从程序集'mscorlib,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'加载类型'System.Reflection.AssemblySignatureKeyAttribute'.System.ModuleHandle.ResolveType(RuntimeModule模块,Int32 typeToken,Int Ptr*typeInstArgs,Int32 typeInstCount,IntPtr*methodInstArgs,Int32 methodInst Count,ObjectHandleOnStack类型)在System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule模块,Int32 typeToken,RuntimeTypeHandle [] typeInstantiationContext,在System.Reflection.CustomAttribute的System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken,Type [] ge nericTypeArguments,Type [] genericMethodArguments)的RuntimeTypeHandle []遇到hodInstantiationContext).
在System.Reflection.InstallUtil.Main(String [] args)的System.Reflection.RuntimeAssembly.GetCustomAttributes(Type attributeType,Boolean inherit)上的System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly,m mly,RuntimeType caType)
似乎即使是InstallUtil也无法启动,因此无法安装该服务.
我该怎么检查?
我有一个应用程序,我想收集指定级别和标记的LogCat消息.
我能以某种方式获得累积的消息吗?我不想逐个收集消息,它应该是它们的总和,就像我使用adb来读取实际日志一样.这可能吗?
我在每次单击地图时都添加了一个标记,而我只想查看最后一个。
我尝试了以下代码:
if(marker!=null)
{
marker.visible(false);
marker=null;
}
marker=new MarkerOptions().position(latLng);
googleMap.addMarker(marker);
Run Code Online (Sandbox Code Playgroud)
即使将其设置为不可见,我也会看到每个标记。
每次点击后如何删除?我找不到任何删除方法。
我的应用程序在后台,我使用的服务在满足某个条件时发送广播:
if(send)
{
Intent intent = new Intent(Tags.MSG_BROADCAST_ID);
intent.putExtra(Tags.MESSAGE, msg);
Log.w(Tags.DEBUG,"Broadcast");
sendBroadcast(intent);
}
}
Run Code Online (Sandbox Code Playgroud)
我的广播接收器获得广播,它应该显示一个警告对话框.我用这个:
public void onReceive(Context context, Intent intent)
{
Bundle bundle = intent.getExtras();
if (bundle != null && Globals.MainActivity != null)
{
msg = bundle.getString(Tags.MESSAGE);
Globals.MainActivity.ShowMessage(msg);
}
}
Run Code Online (Sandbox Code Playgroud)
当我的主要活动位于前台时,警报会正确显示.当它在后台时,什么都看不见.
Runnable runnable = new Runnable()
{
public void run()
{
KeyguardManager km = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
final KeyguardManager.KeyguardLock kl = km.newKeyguardLock("My_App");
kl.disableKeyguard();
PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.FULL_WAKE_LOCK, "My_App");
wl.acquire();
AlertDialog.Builder alertDialogBuilder = new …Run Code Online (Sandbox Code Playgroud) 我有一个ASP.Net项目(ProjA)和一个类库项目(LibB).我在库中创建了一个自定义类(ClassC),并添加了对现有dll(DllD)的引用.
我在ProjA中选择了Add reference选项,并从Solution选项卡中选择了LibB并添加了引用.
在ProjA中,我创建了一个ClassC实例.令我惊讶的是,它没有编译并向我显示错误:必须添加DllD作为我的ProjA的参考.
这是消息:
"XXXX"类型在未引用的程序集中定义.您必须添加对程序集"YYYYYY,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = xxxxxxx"的引用.
好吧,XXX是ClassC的基础,并且在LibB项目中引用了dll.
那么LibB有什么意义呢?我不想将DllD添加到我的ProjA项目中,我只想在另一个项目中使用依赖于它的自定义类.
我必须添加这样的dll是正常的吗?我应该设置什么来使我的LibB包含DllD dll?
我打算为每个可见行创建一个具有不同布局的列表视图.我也定了setStackFromBottom(true).
我知道我可以使用int getItemViewType(int position)的View getView(int position, View convertView, ViewGroup parent),但它使用的固定位置,而不是基于显眼的位置.
我想使用listview,如下面的概念所示:

如果我向下滚动,下一个项目应该替换前一个项目并使用其大型布局.我尝试使用以下代码,但它使用修复位置,因此列表中的最后一项始终是最大的,而不是最后一个可见项.
@Override
public int getItemViewType(int position)
{
if(position==values.length-1)
return 1;
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = null;
type=getItemViewType(position);
if (type == 0)
rowView = inflater.inflate(R.layout.list_item, parent, false);
else
rowView = inflater.inflate(R.layout.list_item2, parent, false);
return rowView;
}
Run Code Online (Sandbox Code Playgroud)
我想,我应该得到适配器内第一个和最后一个可见项的位置,但我不知道该怎么做.
我可以以某种方式创建一个遵循上述概念的列表视图吗?我可以获得正确的职位吗?
我安装了 Visual Studio 2019 16.8.3(从 16.8.2 升级)。
升级后,我无法打开任何.NET Core相关项目,因为出现以下错误:
无法打开项目文件。无法找到 .NET SDK。检查它是否已安装,以及 global.json 中指定的版本(如果有)是否与已安装的版本匹配。
所以我决定分别安装.Net Core 3.1 SDK和.Net 5 SDK。
安装成功后,我仍然没有安装任何SDK。
我该怎么办(除了 VS 完全修复)?