我创建了一个名为的自定义视图Graphview
.这是GraphView类的结构.
public class GraphView extends View {
public GraphView(Context context, float[] values, String title, String[] horlabels, String[] verlabels, boolean type) {
super(context);
........
}
..................
.................
}
Run Code Online (Sandbox Code Playgroud)
我已经在一个tablerow中添加了视图addview()
.它工作正常.现在我想设置高度和宽度GraphView
.怎么做?
是否有可能在ViewController类中检查它是否显示为模态视图控制器?
如何从View(aspx页面)中访问ModelState?
应该何时在实际的表上使用View?我应该期望这会产生什么收益?
总的来说,在表格上使用视图有什么好处?我不应该以视图首先看起来的方式设计表格吗?
想象一个常见的场景,这是我遇到的更简单的版本.我实际上有几层进一步筑巢......
但这就是场景
主题包含列表类别包含列表产品包含列表
我的控制器提供了一个完全填充的主题,包含该主题的所有类别,此类别中的产品及其订单.
订单集合有一个名为Quantity(以及许多其他)的属性需要可编辑.
@model ViewModels.MyViewModels.Theme
@Html.LabelFor(Model.Theme.name)
@foreach (var category in Model.Theme)
{
@Html.LabelFor(category.name)
@foreach(var product in theme.Products)
{
@Html.LabelFor(product.name)
@foreach(var order in product.Orders)
{
@Html.TextBoxFor(order.Quantity)
@Html.TextAreaFor(order.Note)
@Html.EditorFor(order.DateRequestedDeliveryFor)
}
}
}
Run Code Online (Sandbox Code Playgroud)
如果我使用lambda然后我似乎只获得对顶级Model对象的引用,"Theme"不是foreach循环中的那些.
是我试图在那里做甚至可能还是我高估或误解了什么是可能的?
有了上面我在TextboxFor,EditorFor等上得到了一个错误
CS0411:无法从用法中推断出方法'System.Web.Mvc.Html.InputExtensions.TextBoxFor(System.Web.Mvc.HtmlHelper,System.Linq.Expressions.Expression>)'的类型参数.尝试显式指定类型参数.
谢谢.
我正在尝试创建一个自定义视图,它将取代我在多个地方使用的某个布局,但我正在努力这样做.
基本上,我想替换这个:
<RelativeLayout
android:id="@+id/dolphinLine"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@drawable/background_box_light_blue"
android:padding="10dip"
android:layout_margin="10dip">
<TextView
android:id="@+id/dolphinTitle"
android:layout_width="200dip"
android:layout_height="100dip"
android:layout_alignParentLeft="true"
android:layout_marginLeft="10dip"
android:text="@string/my_title"
android:textSize="30dip"
android:textStyle="bold"
android:textColor="#2E4C71"
android:gravity="center"/>
<Button
android:id="@+id/dolphinMinusButton"
android:layout_width="100dip"
android:layout_height="100dip"
android:layout_toRightOf="@+id/dolphinTitle"
android:layout_marginLeft="30dip"
android:text="@string/minus_button"
android:textSize="70dip"
android:textStyle="bold"
android:gravity="center"
android:layout_marginTop="1dip"
android:background="@drawable/button_blue_square_selector"
android:textColor="#FFFFFF"
android:onClick="onClick"/>
<TextView
android:id="@+id/dolphinValue"
android:layout_width="100dip"
android:layout_height="100dip"
android:layout_marginLeft="15dip"
android:background="@android:drawable/editbox_background"
android:layout_toRightOf="@+id/dolphinMinusButton"
android:text="0"
android:textColor="#2E4C71"
android:textSize="50dip"
android:gravity="center"
android:textStyle="bold"
android:inputType="none"/>
<Button
android:id="@+id/dolphinPlusButton"
android:layout_width="100dip"
android:layout_height="100dip"
android:layout_toRightOf="@+id/dolphinValue"
android:layout_marginLeft="15dip"
android:text="@string/plus_button"
android:textSize="70dip"
android:textStyle="bold"
android:gravity="center"
android:layout_marginTop="1dip"
android:background="@drawable/button_blue_square_selector"
android:textColor="#FFFFFF"
android:onClick="onClick"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
这样:
<view class="com.example.MyQuantityBox"
android:id="@+id/dolphinBox"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:myCustomAttribute="@string/my_title"/>
Run Code Online (Sandbox Code Playgroud)
所以,我不想要一个自定义布局,我想要一个自定义视图(这个视图不应该有子视图).
唯一可以从MyQuantityBox的一个实例改为另一个实例的是标题.我非常希望能够在XML中指定它(就像我在最后的XML行上那样)
我怎样才能做到这一点?我应该将RelativeLayout放在/ res/layout中的XML文件中并在MyBoxQuantity类中对其进行充气吗?如果是,我该怎么办?
谢谢!
我有这样的观点:
CREATE VIEW MyView AS
SELECT Column FROM Table WHERE Value = 2;
Run Code Online (Sandbox Code Playgroud)
我想让它更通用,它意味着将2变为变量.我试过这个:
CREATE VIEW MyView AS
SELECT Column FROM Table WHERE Value = @MyVariable;
Run Code Online (Sandbox Code Playgroud)
但MySQL不允许这样做.
我找到了一个丑陋的解决方法:
CREATE FUNCTION GetMyVariable() RETURNS INTEGER DETERMINISTIC NO SQL
BEGIN RETURN @MyVariable; END|
Run Code Online (Sandbox Code Playgroud)
然后观点是:
CREATE VIEW MyView AS
SELECT Column FROM Table WHERE Value = GetMyVariable();
Run Code Online (Sandbox Code Playgroud)
但它看起来很糟糕,而且用法也很糟糕 - 我必须在每次使用视图之前设置@MyVariable.
有没有解决方案,我可以像这样使用:
SELECT Column FROM MyView(2) WHERE (...)
Run Code Online (Sandbox Code Playgroud)
具体情况如下:我有一个表存储有关被拒绝请求的信息:
CREATE TABLE Denial
(
Id INTEGER UNSIGNED AUTO_INCREMENT,
PRIMARY KEY(Id),
DateTime DATETIME NOT NULL,
FeatureId MEDIUMINT …
Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的onClick(View v)XML中调用该方法,但不能与Fragment一起使用.这是错误.
01-17 12:38:36.840: E/AndroidRuntime(4171): java.lang.IllegalStateException:
Could not find a method insertIntoDb(View) in the activity class main.MainActivity
for onClick handler on view class android.widget.Button with id 'btn_conferma'
Run Code Online (Sandbox Code Playgroud)
MainActivity.java
public void insertIntoDb(View v) {
...
}
Run Code Online (Sandbox Code Playgroud)
xml代码
<Button
android:id="@id/btn_conferma"
style="?android:attr/borderlessButtonStyle"
android:layout_width="0.0dip"
android:layout_height="45dp"
android:layout_marginLeft="2dp"
android:layout_weight="1.0"
android:background="@drawable/bottoni"
android:gravity="center_horizontal|center_vertical"
android:onClick="insertIntoDb"
android:text="SALVA"
android:textColor="#ffffff"
android:textSize="16sp" />
Run Code Online (Sandbox Code Playgroud) 在SQL Server 2008中给出
TableA(A_ID, A_Data)
TableB(B_ID, B_Data)
ViewC(A_or_B_ID, A_or_B_Data)
Run Code Online (Sandbox Code Playgroud)
是否可以定义TableZ(A_or_B_ID, Z_Data)
这样的Z.A_or_B_ID
列被约束到在ViewC
?中找到的值?可以使用外键来查看视图吗?
view ×10
android ×4
asp.net ×2
asp.net-mvc ×1
button ×1
c# ×1
click ×1
controller ×1
foreign-keys ×1
height ×1
ios ×1
iphone ×1
layout ×1
modal-dialog ×1
modelstate ×1
mysql ×1
parameters ×1
params ×1
razor ×1
sql ×1
sql-server ×1
width ×1
xml ×1