我在项目代码中随处可见,当按钮在后台声明时,而不是通常的Button。这样做的开发人员 - 现在不工作了。为什么这样做?是否有一些表现获胜?或者是什么原因? 我如何用ConstraineLayout做同样的效果?感谢。
<android.support.v7.widget.CardView
android:id="@+id/confirm_phone_btn_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/confirm_phone_text_input_layout"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="22dp"
android:layout_marginTop="32dp"
android:background="@color/edit_info_btn_inactive"
app:cardBackgroundColor="@color/blue"
app:cardCornerRadius="3dp"
app:cardElevation="2dp"
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="false">
<TextView
android:id="@+id/confirm_phone_change_txt"
android:layout_width="118dp"
android:layout_height="36dp"
android:layout_gravity="center_horizontal"
android:background="@color/edit_info_btn_inactive"
android:clickable="true"
android:gravity="center"
android:includeFontPadding="false"
android:text="@string/change"
android:textAllCaps="true"
android:textColor="@color/white"
android:textSize="14sp"
android:textStyle="bold" />
</android.support.v7.widget.CardView>
答案 0 :(得分:0)
在活动xml文件中添加cardview
public void onClickCardview(View view){
//your code here
}
在活动Java文件中添加以下代码
public void save_vendor_info()
{
SqlConnection con = new SqlConnection(@"server=localhost;Database=TEST;integrated security=true");
con.Open();
DataTable dt = new DataTable();
XmlDocument doc = new XmlDocument();
doc.Load("https://testdata/api/vendordata");
try
{
XmlNode node = doc.DocumentElement.ChildNodes.Cast<XmlNode>().ToList()[0];
foreach (XmlNode column in node.ChildNodes)
{
dt.Columns.Add(column.Name, typeof(String));
}
XmlNode Filas = doc.DocumentElement;
foreach (XmlNode Fila in Filas.ChildNodes)
{
List<string> Valores = Fila.ChildNodes.Cast<XmlNode>().ToList().Select(x => x.InnerText).ToList();
SqlCommand cmd = new SqlCommand(("IF NOT EXISTS (Select Vendorcode From Vendors where Vendorcode = @Vendorcode) INSERT INTO Vendors VALUES (@Vendorcode, @STCD3, @Name1, @Name2, @Name3, @street1, @street2, @street3, @city1, @city2, @city3, @state1, @state2, @state3, @zip1, @zip2, @zip3, @countrycode, @BusinessUnitId, @VATID, @nationalVATID, @IBAN, @BankAccount, @BankCode)"), con);
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@Vendorcode", Valores[0]);
cmd.Parameters.AddWithValue("@STCD3", Valores[1]);
cmd.Parameters.AddWithValue("@Name1", Valores[2]);
cmd.Parameters.AddWithValue("@Name2", Valores[3]);
cmd.Parameters.AddWithValue("@Name3", Valores[4]);
cmd.Parameters.AddWithValue("@street1", Valores[5]);
cmd.Parameters.AddWithValue("@street2", Valores[6]);
cmd.Parameters.AddWithValue("@street3", Valores[7]);
cmd.Parameters.AddWithValue("@city1", Valores[8]);
cmd.Parameters.AddWithValue("@city2", Valores[9]);
cmd.Parameters.AddWithValue("@city3", Valores[10]);
cmd.Parameters.AddWithValue("@state1", Valores[11]);
cmd.Parameters.AddWithValue("@state2", Valores[12]);
cmd.Parameters.AddWithValue("@state3", Valores[13]);
cmd.Parameters.AddWithValue("@zip1", Valores[14]);
cmd.Parameters.AddWithValue("@zip2", Valores[15]);
cmd.Parameters.AddWithValue("@zip3", Valores[16]);
cmd.Parameters.AddWithValue("@countrycode", Valores[17]);
cmd.Parameters.AddWithValue("@BusinessUnitId", Valores[18]);
cmd.Parameters.AddWithValue("@VATID", Valores[19]);
cmd.Parameters.AddWithValue("@nationalVATID", Valores[20]);
cmd.Parameters.AddWithValue("@IBAN", Valores[21]);
cmd.Parameters.AddWithValue("@BankAccount", Valores[22]);
cmd.Parameters.AddWithValue("@BankCode", Valores[23]);
cmd.ExecuteNonQuery();
}
}
catch (Exception ex)
{
}
}