- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
biên tập:
package com.walkindeep.teammanagerpreview;
import android.content.Context;
import android.os.Bundle;
import android.support.design.widget.BottomSheetBehavior;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.Toast;
import com.dexafree.materialList.card.Card;
import com.dexafree.materialList.card.CardProvider;
import com.dexafree.materialList.card.OnActionClickListener;
import com.dexafree.materialList.card.action.TextViewAction;
import com.dexafree.materialList.listeners.OnDismissCallback;
import com.dexafree.materialList.view.MaterialListView;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
nhập java.util.ArrayList;
nhập java.util.HashMap;
nhập java.util.List;
public class MyTaskActivity extends NavigationActivity {
private Context mContext = this;
@Ghi đè
được bảo vệ void onCreate(Gói savedInstanceState) {
super.onCreate(savedInstanceState);
/*全局导航栏*/
LayoutInflater inflater = (LayoutInflater) this
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View contentView = inflater.inflate(R.layout.activity_task, null, false);
drawer.addView(contentView, 0);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.floatingActionButtionTask);
fab.setOnClickListener(new View.OnClickListener() {
@Ghi đè
public void onClick(View view) {
View bottomSheet = findViewById(R.id.bottom_sheet);
BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet);
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
}
});
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
/*cardView*/
// initCard();
final User user = User.init("xxx", "xxx");
updateTask(user);
/*下滑刷新*/
final SwipeRefreshLayout swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.SwipeRefreshLayout);
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Ghi đè
public void onRefresh() {
updateTask(user, swipeRefreshLayout);
}
});
}
/*更新任务数据*/
private void updateTask(User user, SwipeRefreshLayout swipeRefreshLayout) {
DataHandler dataHandler = new DataHandler();
dataHandler.getData("issues.json?assigned_to_id=me" + "&status_id=1", this, user);
swipeRefreshLayout.setRefreshing(false);
}
/*更新任务数据*/
private void updateTask(User user) {
DataHandler dataHandler = new DataHandler();
dataHandler.getData("issues.json?assigned_to_id=me" + "&status_id=1", this, user);
}
private Card[] jsonToCards(JSONObject userIssuesJSONObjectTemp) {
JSONArray userIssuesJSONArray = null;
thử {
userIssuesJSONArray = userIssuesJSONObjectTemp.getJSONArray("issues");
} catch (JSONException e) {
e.printStackTrace();
}
List cards = new ArrayList<>();
/*用于存储所有issue的list*/
List issueList = Issue.getIssueList();
issueList.clear();
for (int i = 0; i < userIssuesJSONArray.length(); i++) {
thử {
/*创建issue类*/
Issue issue = new Issue(userIssuesJSONArray.getJSONObject(i).getString("subject"), userIssuesJSONArray.getJSONObject(i).getString("description"), userIssuesJSONArray.getJSONObject(i).getInt("id"));
issueList.add(issue);
Card card = new Card.Builder(this)
.withProvider(new CardProvider())
.setLayout(R.layout.material_basic_buttons_card)
.setTitle(issue.getSubject())
.setDescription(issue.getDescription())
.addAction(R.id.left_text_button, new TextViewAction(this)
.setText("按钮1")
.setTextResourceColor(R.color.black_button)
.setListener(new OnActionClickListener() {
@Ghi đè
public void onActionClicked(View view, Card card) {
Toast.makeText(mContext, "You have pressed the left button", Toast.LENGTH_SHORT).show();
}
}))
.addAction(R.id.right_text_button, new TextViewAction(this)
.setText("按钮2")
.setTextResourceColor(R.color.accent_material_dark)
.setListener(new OnActionClickListener() {
@Ghi đè
public void onActionClicked(View view, Card card) {
Toast.makeText(mContext, "You have pressed the right button", Toast.LENGTH_SHORT).show();
}
}))
.endConfig()
.xây dựng();
card.setTag(issue);//设置卡片和issue关联
cards.add(card);
} catch (JSONException e) {
e.printStackTrace();
}
}
return cards.toArray(new Card[cards.size()]);
}
public void setCardsToUI(Card[] cards) {
final MaterialListView mListView = (MaterialListView) findViewById(R.id.material_listview);
mListView.getAdapter().clearAll();
for (int i = 0; i < cards.length; i++) {
mListView.getAdapter().add(cards[i]);
/*设置卡片可以滑动删除*/
cards[i].setDismissible(true);
}
/*设置滑动删除操作*/
mListView.setOnDismissCallback(new OnDismissCallback() {
public void onDismiss(final Card card, final int position) {
Snackbar.make(mListView, "已标记完成", Snackbar.LENGTH_LONG)
.setCallback(new Snackbar.Callback() {
@Ghi đè
public void onDismissed(Snackbar snackbar, int event) {
if (event == DISMISS_EVENT_ACTION) {//do nothing but recover card
mListView.getAdapter().add(position, card);
} khác {
Issue issue = (Issue) card.getTag();
issue.setStatusid(3);
issue.pushStatusName(mContext);
List issueList = Issue.getIssueList();
}
}
})
.setAction("撤销", new View.OnClickListener() {
@Ghi đè
public void onClick(View v) {
}
})
.show();
}
});
}
class DataHandler extends AbstractDataQuery {
@Ghi đè
protected void work(JSONObject userIssuesJSONObject) {
Card[] cards = jsonToCards(userIssuesJSONObject);
setCardsToUI(cards);
}
}
}
当点击 float 操作按钮“+”时,bottomsheet 显示如下:
这是 activity_task.xml 文件:
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="phù hợp với cha mẹ"
android:layout_height="match_parent"
android:fitsSystemWindows="đúng"
tools:context=".MyTaskActivity">
android:layout_width="phù hợp với cha mẹ"
android:layout_height="match_parent"
android:orientation="vertical">
<>
android:layout_width="phù hợp với cha mẹ"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<>
android:id="@+id/toolbar"
android:layout_width="phù hợp với cha mẹ"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
<>
android:layout_width="phù hợp với cha mẹ"
android:id="@+id/bottom_sheet"
android:layout_height="wrap_content"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior">
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<>
android:id="@+id/buildProjectButton"
android:layout_width="phù hợp với cha mẹ"
android:layout_height="wrap_content"
android:text="@string/buildProject" />
<>
android:id="@+id/buildTaskButton"
android:layout_width="phù hợp với cha mẹ"
android:layout_height="wrap_content"
android:text="@string/buildTask" />
<>
android:id="@+id/floatingActionButtionTask"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/ic_input_add" />
一切似乎都很好,但是当我点击 Bottom Sheet 单上方时,它并没有像我预期的那样完全消失:
怎么了?
câu trả lời hay nhất
"By attaching a BottomSheetBehavior to a child View of a
CoordinatorLayout
(i.e., addingapp:layout_behavior=”android.support.design.widget.BottomSheetBehavior”)
, you’ll automatically get the appropriate touch detection to transition between five state...".Try changing yourLinear Layout
ĐẾNFrame Layout
will do.
尝试这样使用。
<>
android:id="@+id/bottom_sheet"
android:layout_width="phù hợp với cha mẹ"
android:layout_height="wrap_content"
android:background="#ff0000"
app:behavior_hideable="true"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior">
<>
android:id="@+id/buildProjectButton"
android:layout_width="phù hợp với cha mẹ"
android:layout_height="wrap_content"
android:text="@string/buildProject" />
<>
android:id="@+id/buildTaskButton"
android:layout_width="phù hợp với cha mẹ"
android:layout_height="wrap_content"
android:text="@string/buildTask" />
修改你的代码。
View bottomSheet = findViewById(R.id.bottom_sheet);
BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet);
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
bottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
@Ghi đè
public void onStateChanged(@NonNull View bottomSheet, int newState) {
// React to state change
Log.e("onStateChanged", "onStateChanged:" + newState);
if (newState == BottomSheetBehavior.STATE_EXPANDED) {
// Hide your state here.
}
}
@Ghi đè
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
// React to dragging events
Log.e("onSlide", "onSlide");
}
});
编辑 1:
默认情况下, Bottom Sheet 行为不可隐藏。你需要添加这个。
bottomSheetBehavior.setHideable(true);
关于android: bottomsheet 不会正常消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37087352/
Đã thử sử dụng trình chỉnh sửa biểu mẫu được tích hợp vào QTCreator nhưng ngay cả khi tôi đặt plugin vào QtCreator.app/Contents/MacOS/designer thì nó cũng không hiển thị. Tuy nhiên, cùng một tệp dylib hoạt động độc lập
Trong ví dụ mã này. Điều gì sẽ được đọc sau "this.method2();"? Nó có chuyển sang phương thức 2() trước khi trả về Giá trị trả về không? phương thức int công khai1(int returnV
Dự án của tôi có các phần phụ thuộc được định cấu hình thông qua gradle. Tôi muốn thêm các phần phụ thuộc sau: nhóm biên dịch: 'org.restlet.jse', tên: 'org.restlet.ext.apispark', v
Tôi sẽ chuyển phần mềm quản lý khách hàng trên Windows sang phần mềm trên Web. Tôi thấy rằng polymer có thể là một lựa chọn. Tuy nhiên, để sử dụng, chúng tôi không thể tìm thấy thành phần polymer với Chế độ xem bảng, menu thả xuống
Có một thư mục trong thư mục dự án của tôi Dự án, chẳng hạn như thư mục ED, khi tôi chỉ định trong Eclipse nơi tìm các tệp tôi viết File file = new File("ED/text.txt");
Đây là điều kỳ lạ, nó hoạt động: $('#box').css({"backgroundPosition": "0px 250px"}); nhưng nó không hoạt động, nó chỉ không thay đổi vị trí: $('# hộp') .animate
Câu hỏi này đã có câu trả lời ở đây: Tại sao OR làm tròn số trong Javascript? (3 câu trả lời) Đã đóng 5 năm trước. Hướng dẫn JavaScript của Mozilla
Câu hỏi này đã có câu trả lời ở đây: Hàm strcmpi có trong thư viện tiêu chuẩn C của ISO không? (3 câu trả lời) Đã đóng cửa 8 năm trước. Tôi có một câu hỏi tại sao
Tôi hiện đang sử dụng gói lưu trữ được chia sẻ và tôi không chắc nó đang sử dụng phiên bản MySQL nào, nhưng có vẻ như nó không hỗ trợ loại DATETIMEOFFSET. Có phiên bản MySQL nào hỗ trợ DATETIMEOFFSET không? Hoặc có kế hoạch
Khi nghiên cứu Seam 3, tôi phát hiện ra rằng Seam Solder cho phép áp dụng chú thích @Named cho các gói - trong trường hợp này, tất cả các hạt trong gói sẽ tự động được đặt tên như thể chúng được @Named. Tôi không thấy
Tôi biết rằng .append đôi khi sẽ tăng dung lượng của mảng và tạo thành một bản sao mới của mảng, nhưng .removeLast sẽ đảo ngược điều này và giảm dung lượng của mảng bằng cách sao chép sang một mảng mới nhỏ hơn? Câu trả lời tốt nhất là không (hoặc ít nhất nếu có thì đó là một lỗi
Thật khó để nói những gì để hỏi ở đây. Câu hỏi không rõ ràng, mơ hồ, không đầy đủ, quá rộng hoặc hùng biện và không thể trả lời hợp lý ở dạng hiện tại. Để được trợ giúp làm rõ vấn đề này để có thể mở lại, hãy truy cập trung tâm trợ giúp Đóng 1.
Công cụ xác định hàm noException có nhằm mục đích tăng hiệu suất hay không, vì có thể không có mã trong đối tượng được tạo để ghi lại các ngoại lệ, do đó, nó phải được thêm vào các khai báo và định nghĩa hàm bất cứ khi nào có thể? Lần đầu tiên tôi nghĩ đến một trình bao bọc cho các đối tượng có thể gọi được, trong đó không có ngoại lệ nào có thể tạo ra
Tôi đang sử dụng Angularjs 1.3.7 và mới phát hiện ra rằng Promise.all không cập nhật Chế độ xem Angularjs sau khi phản hồi thành công, trong khi $q.all thì có. Vì Lời hứa được bao gồm trong bản gốc
Gần đây tôi đã tìm thấy mã JavaScript này: Math.random() * 0x1000000 10.12345 10.12345 >> 0 10 > 10.12345 >>> 0 10 Tôi sử dụng
Tôi đang viết một thư viện vectơ đồ chơi (vật lý) và tôi đang gặp phải một vấn đề trong đó GHC khẳng định rằng các hàm phải có Integer. là kiểu của họ. Tôi muốn nhân vectơ với vectơ cũng như đại lượng vô hướng (chỉ sử dụng * ), mặc dù điều này có thể đạt được bằng cách chỉ sử dụng Vector
Hàm mail() của PHP gửi thư tốt, nhưng Swift_MailTransport của Swiftmailer không hoạt động!
Tôi đã thử kết xuất dữ liệu của mình qua tập lệnh php nhưng không có dòng lệnh. Vì vậy, tôi đã tạo tệp .sql của mình bằng cách sử dụng tập lệnh này và sau đó tôi đã thử sử dụng tập lệnh của mình: $link = mysql_connect($host, $u
Sử dụng thư viện chuẩn sqlite3 trong Python 2.6.4, truy vấn sau chạy tốt trên dòng lệnh sqlite3: select đoạnid, node_t, start, number,title
Gần đây tôi đã tìm thấy mã JavaScript này: Math.random() * 0x1000000 10.12345 10.12345 >> 0 10 > 10.12345 >>> 0 10 Tôi sử dụng
Tôi là một lập trình viên xuất sắc, rất giỏi!