base.OnModelCreating(modelBuilder);
modelBuilder.HasDefaultSchema("AUTH_DEV");
modelBuilder
.Properties()
.Where(p => p.PropertyType == typeof(string) &&
!p.Name.Contains("Id") &&
!p.Name.Contains("Provider"))
.Configure(p => p.HasMaxLength(256));
modelBuilder.Entity<CustomRole>().ToTable("AspNetRoles").Property(c => c.Name).HasMaxLength(128).IsRequired();
modelBuilder.Entity<ApplicationUser>().ToTable("AspNetUsers").Property(c => c.UserName).HasMaxLength(128).IsRequired();
modelBuilder.Entity<ApplicationUser>().ToTable("AspNetUsers").Property(c => c.Email).HasMaxLength(128).IsRequired();
modelBuilder.Entity<CustomRole>()
.HasKey(r => new { r.Id })
.ToTable("AspNetRoles");
modelBuilder.Entity<CustomUserClaim>()
.HasKey(r => new { r.Id })
.ToTable("AspNetUserClaims");
modelBuilder.Entity<CustomUserRole>()
.HasKey(r => new { r.UserId, r.RoleId })
.ToTable("AspNetUserRoles");
modelBuilder.Entity<CustomUserLogin>()
.HasKey(l => new { l.LoginProvider, l.ProviderKey })
.ToTable("AspNetUserLogins");
modelBuilder.Entity<CustomUserRole>().ToTable("AspNetUserRoles");
modelBuilder.Entity<CustomUserLogin>().ToTable("AspNetUserLogins");
modelBuilder.Entity<CustomUserClaim>().ToTable("AspNetUserClaims");
}
}
在这里,我正在显示mysql数据库中的事件列表,我希望用户可以单击列表记录并将它们带到记录的所有详细信息的下一个活动中,为此我需要通过记录ID。 我试图通过意图将其传递给数组位置,但是我没有得到预期的结果,我认为我传递了错误的值,有人可以告诉我我必须在这里传递什么。我是java和android studio的新手,所以很抱歉缺少细节。
答案 0 :(得分:0)
您应该在这里做什么
DataModel model = (DataModel) listData.get(position);
intent.putExtra("ListViewValue", model);
startActivity(intent);
您的DataModel应该implements Serializable
这应该可以解决您的问题。
答案 1 :(得分:0)
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// get postion from arraylist
modelclass u = arrayList.get(position);
Intent in = new Intent(currentacticity.this, nextactivity.class);
in.putExtra("send", u);
startActivity(in);
}
});