单击activity_main.xml上的about us按钮后,我一直无法找到将用户发送到xml的方法
MainActivity 我在这里声明了在Dat_menu.xml
中创建的ArrayAdapterpackage com.example.vitoriano_vaz.eastbayvapes;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.ArrayAdapter;
import android.widget.ListView;
/*
This app is for a local Vape Shop
it's purpose is to increase customer flow, and provide a menu for Android users
the array is going to be called = da_menu
*/
public class MainActivity extends AppCompatActivity {
/*
called when the user clicks the send Button
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
populateListView();
}
private void populateListView() {
// Create the list of items
String[] juiceMenu= {
"#1 BlueBerry Bombshell",
"#2 Richie Rich",
"#3 Chiquita",
"#4 Afternoon Delight",
"#5 Poppin Otters",
"#6 Viva La Sangria",
"#7 Okole Maluna",
"#8 Carmen Miranda",
"#9 Pomalade",
"#10 Izual",
"#11 Butter Stotch",
"#12 Blue Bulls",
"#13 Grape Ape",
"#14 Bruce Juice",
"#15 Doc Holiday",
"#16 Peachy Keen",
"#17 Hula",
"#18 New York",
"#19 Al Gore",
"#20 Lux Charms",
"#21 Sailor Jack",
"#22 Get Him to the Greek",
"#23 Key We Lie Chi",
"#24 Spring Fling",
"#25 Gumby",
"#26 Chai-Milk",
"#27 Mr. Bean",
"#28 50 Shades of Orange",
"#29 Blue Waffles",
"#30 Enigma",
"#31 Mr. Freeze",
"#32 Cup of Joe"};
// Build adapter
ArrayAdapter<String> adapter = new ArrayAdapter<String>(
this, // context for the activity
R.layout.da_menu, // Layout to create
juiceMenu); // Items to be displayed
//configure list view
ListView list = (ListView) findViewById(R.id.listViewMain);
list.setAdapter(adapter);
}
}
Activty_main.xml 这里我在ListView中显示ArrayAdapter
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:background="#FFFAFA"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.vitoriano_vaz.eastbayvapes.MainActivity">
<TextView
android:textAllCaps="true"
android:textSize="22sp"
android:textStyle="bold"
android:textColor="#000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Welcome to East Bay Vapes"
android:id="@+id/textView" />
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/listViewMain"
android:layout_centerHorizontal="true"
android:layout_below="@+id/buttonAboutUs" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="About Us"
android:id="@+id/buttonAboutUs"
android:onClick="onClick"
android:layout_below="@+id/textView"
android:layout_centerHorizontal="true" />
</RelativeLayout>
aboutus.xml 这是我想要用户点击buttonAboutUs后发送的xml 我经常遇到问题,似乎无法找到有效的解决方案。我试过ViewSwitcher但似乎无法让它工作。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#8800FF"
android:id="@+id/myRelativeLayout"
android:inAnimation="@android:anim/slide_in_left">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="About Us"
android:id="@+id/AboutUs"
android:textStyle="bold"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:ems="10"
android:id="@+id/editText2"
android:text="bayvapes@gmail.com"
android:textStyle="bold"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/AboutUs" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPostalAddress"
android:ems="10"
android:id="@+id/editText3"
android:layout_below="@+id/editText2"
android:text="1555 S Vasco RD Liver, Ca 94551"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:textStyle="bold" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="phone"
android:ems="10"
android:id="@+id/editText4"
android:layout_below="@+id/editText3"
android:text="(925)-961-9000"
android:textStyle="bold"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/editText5"
android:layout_below="@+id/editText4"
android:text="facebook.com/bayvapes"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:textStyle="bold" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/editText6"
android:layout_below="@+id/editText5"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:text="Instagram: @bayvapes"
android:textStyle="bold" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:ems="10"
android:id="@+id/editText7"
android:layout_below="@+id/editText6"
android:text="Monday - Saturday 10:00 am - 8:00 pm\n Sunday 10:00 am - 6:00 pm"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true" />
</
答案 0 :(得分:0)
首先在#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#define M 1
#define MAXN 5000000
char c[MAXN], *a[MAXN];
int pstrcmp(char **p, char **q){
return strcmp(*p, *q);
}
int main(){
int i, ch, n = 0, maxi, maxlen = -1;
while ((ch = getchar()) != EOF) {
a[n] = &c[n];
c[n++] = ch;
}
c[n] = 0;
qsort(a, n, sizeof(char *), pstrcmp);
printf("%s",a[1]);
return 0;
}
activity_main.xml
在<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click Me" />
MainActivity.java
现在创建一个您称之为关于我们的新活动<}添加您要在Button button=(Button)findViewById(R.id.button);
现在为about_us.xml
中的按钮点击此ClickListener
。
MainActivity.java
答案 1 :(得分:0)
在MainActivity中定义一个像这样的onClick方法。
public void onClick(View view){
Intent intent = new Intent(MainActivity.this, AboutUs.class); // this is AboutUs activity
startActivity(intent); // start the intent to go to AboutUs Screen
}
您在MainActivity Class
中缺少上述方法答案 2 :(得分:0)
创建一个像AboutActivity.class这样的活动,并将其添加到清单文件
中<activity android:name=".AboutActivity"/>
现在在MainActivity.class中创建以下方法
public void onClick(View v) {
Intent intent=new Intent(MainActivity.this, AboutActivity.class);
//This will send user to your about activity
startActivity(intent);
}