forked from XRecyclerView/XRecyclerView
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request XRecyclerView#48 from mahuafactory/master
支持setEmptyView
- Loading branch information
Showing
6 changed files
with
126 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
app/src/main/java/com/example/xrecyclerview/EmptyViewActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package com.example.xrecyclerview; | ||
|
||
import android.os.Bundle; | ||
import android.os.Handler; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.support.v7.widget.LinearLayoutManager; | ||
import android.view.LayoutInflater; | ||
import android.view.Menu; | ||
import android.view.MenuItem; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
import com.jcodecraeer.xrecyclerview.ProgressStyle; | ||
import com.jcodecraeer.xrecyclerview.XRecyclerView; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class EmptyViewActivity extends AppCompatActivity { | ||
private XRecyclerView mRecyclerView; | ||
private MyAdapter mAdapter; | ||
private ArrayList<String> listData; | ||
private View mEmptyView; | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_recyclerview); | ||
mRecyclerView = (XRecyclerView)this.findViewById(R.id.recyclerview); | ||
LinearLayoutManager layoutManager = new LinearLayoutManager(this); | ||
layoutManager.setOrientation(LinearLayoutManager.VERTICAL); | ||
mRecyclerView.setLayoutManager(layoutManager); | ||
|
||
mEmptyView = findViewById(R.id.text_empty); | ||
|
||
mRecyclerView.setEmptyView(mEmptyView); | ||
|
||
//没有数据,触发emptyView | ||
listData = new ArrayList<String>(); | ||
mAdapter = new MyAdapter(listData); | ||
|
||
mRecyclerView.setAdapter(mAdapter); | ||
} | ||
|
||
@Override | ||
public boolean onCreateOptionsMenu(Menu menu) { | ||
// Inflate the menu; this adds items to the action bar if it is present. | ||
getMenuInflater().inflate(R.menu.menu_main, menu); | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean onOptionsItemSelected(MenuItem item) { | ||
// Handle action bar item clicks here. The action bar will | ||
// automatically handle clicks on the Home/Up button, so long | ||
// as you specify a parent activity in AndroidManifest.xml. | ||
int id = item.getItemId(); | ||
|
||
//noinspection SimplifiableIfStatement | ||
if (id == R.id.action_settings) { | ||
return true; | ||
} | ||
|
||
return super.onOptionsItemSelected(item); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters