如何在 package com.example.user.ayogolf;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.DatePicker;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import com.example.user.ayogolf.Retrofit.ApiServices;
import com.example.user.ayogolf.Retrofit.Caddy;
import com.example.user.ayogolf.Retrofit.InitRetrofit;
import com.example.user.ayogolf.Retrofit.ResponseServer;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Locale;
import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class CoFormActivity extends AppCompatActivity {
@InjectView(R.id.txtcourse)
TextView txtcourse;
@InjectView(R.id.spinnerhour)
Spinner spinnerhour;
@InjectView(R.id.txthour)
TextView txthour;
@InjectView(R.id.spinnerplayer)
Spinner spinnerplayer;
@InjectView(R.id.txtplayer)
TextView txtplayer;
@InjectView(R.id.checkBox3)
CheckBox checkBox3;
@InjectView(R.id.button20)
Button button20;
@InjectView(R.id.txtprice)
TextView txtprice;
@InjectView(R.id.txtn)
TextView txtn;
@InjectView(R.id.buttoncaddy)
Button buttoncaddy;
private DatePickerDialog datePickerDialog;
private SimpleDateFormat dateFormatter;
private TextView tvDateResult;
private Button btDatePicker;
String[] hour = {"--Hour--", "06:00", "06:30", "07:00", "07:30", "12:00", "12:30", "13:00", "13:30"};
String[] player = {"--Player--", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_co_form);
ButterKnife.inject(this);
Intent in = getIntent();
//buat variabel untuk menangkap string yang dipindahkan dari activity lain
String course = in.getStringExtra("course");
String price = in.getStringExtra("price");
txtcourse.setText(course);
txtprice.setText(price);
ArrayAdapter adapterhour = new ArrayAdapter(this, android.R.layout.simple_spinner_item, hour);
spinnerhour.setAdapter(adapterhour);
spinnerhour.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
txthour.setText(hour[position]);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
ArrayAdapter adapterplayer = new ArrayAdapter(this, android.R.layout.simple_spinner_item, player);
spinnerplayer.setAdapter(adapterplayer);
spinnerplayer.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
txtplayer.setText(player[position]);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
dateFormatter = new SimpleDateFormat("yyyy-MM-dd", Locale.US);
tvDateResult = (TextView) findViewById(R.id.tv_dateresult);
btDatePicker = (Button) findViewById(R.id.bt_datepicker);
btDatePicker.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showDateDialog();
}
});
}
private void showDateDialog() {
Calendar newCalendar = Calendar.getInstance();
datePickerDialog = new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
/**
* Method ini dipanggil saat kita selesai memilih tanggal di DatePicker
*/
/**
* Set Calendar untuk menampung tanggal yang dipilih
*/
Calendar newDate = Calendar.getInstance();
newDate.set(year, monthOfYear, dayOfMonth);
/**
* Update TextView dengan tanggal yang kita pilih
*/
tvDateResult.setText(dateFormatter.format(newDate.getTime()));
}
}, newCalendar.get(Calendar.YEAR), newCalendar.get(Calendar.MONTH), newCalendar.get(Calendar.DAY_OF_MONTH));
/**
* Tampilkan DatePicker dialog
*/
datePickerDialog.show();
}
@OnClick({R.id.checkBox3, R.id.button20, R.id.buttoncaddy})
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.buttoncaddy:
//create dialog
final Dialog dialog = new Dialog(CoFormActivity.this);
//set layout custom
dialog.setContentView(R.layout.activity_caddy);
final RecyclerView rvcaddy = (RecyclerView) dialog.findViewById(R.id.rvcaddy);
ArrayList<Caddy> data = new ArrayList<>();
CaddyAdapter adapter = new CaddyAdapter(data, this, R.layout.activity_caddy);
rvcaddy.setAdapter(adapter);
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getApplicationContext());
rvcaddy.setLayoutManager(mLayoutManager);
dialog.show();
break;
case R.id.checkBox3:
//create dialog
//final Dialog dialog = new Dialog(CoFormActivity.this);
//set layout custom
//dialog.setContentView(R.layout.activity_caddy);
//dialog.show();
break;
case R.id.button20:
String hour = txthour.getText().toString();
String player = txtplayer.getText().toString();
String price = txtprice.getText().toString();
if (hour.equalsIgnoreCase("--Hour--")) {
Toast.makeText(this, "Please Choose Time!", Toast.LENGTH_SHORT).show();
} else if (player.equalsIgnoreCase("--Player--")) {
Toast.makeText(this, "Please Choose Number of Player!", Toast.LENGTH_SHORT).show();
} else {
int player2;
player2 = Integer.parseInt(player);
int price2 = Integer.parseInt(price);
int total = price2 * player2;
String total2 = String.valueOf(total).toString();
String price3 = String.valueOf(price2).toString();
//pindah activity dan mengangkut data
Intent intent = new Intent(CoFormActivity.this, ReceiptActivity.class);
//untuk mengangkut data dari class ke class lain
intent.putExtra("course", txtcourse.getText().toString());
intent.putExtra("date", tvDateResult.getText().toString());
intent.putExtra("time", txthour.getText().toString());
intent.putExtra("player", txtplayer.getText().toString());
intent.putExtra("price", price3);
intent.putExtra("total", total2);
if (checkBox3.isChecked()) {
intent.putExtra("caddy", "YES");
} else {
intent.putExtra("caddy", "NO");
}
//eksekusi intent
startActivity(intent);
}
break;
}
}
}
功能
e.g。我在Directory.GetDirectories()
如何仅包含文件夹c:\test1
和aa
来获取ac
或排除Directory.GetDirectories()
和ab
ad
答案 0 :(得分:1)
你可以尝试检查数组元素的名称。就像
一样 Dim rootfolder As String
rootfolder = "c:\test1"
Dim root As String() = Directory.GetDirectories(rootfolder)
Dim rootlist As New List(Of String)
For Each c In root
If Path.GetFileName(c) = "aa" Or Path.GetFileName(c) = "ac" Then '''' c<>"ab" or c<>"ad"
rootlist.Add(c)
End If
Next
Dim root1 As String() = rootlist.ToArray()
很高兴,如果它对你有帮助。