只有在我开始在项目中使用片段后才会出现错误
这是我的代码..
public class MainActivity extends AppCompatActivity {
private Toolbar toolbar;
private ViewPager mPager;
private SlidingTabLayout mTabs;
private MyPagerAdapter adapter;
public static final int product_result = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
toolbar = (Toolbar) findViewById(R.id.app_bar);
setSupportActionBar(toolbar);
assert getSupportActionBar() != null;
getSupportActionBar().setDisplayShowHomeEnabled(true);
NavigationDrawerFragment navigationDrawerFragment = (NavigationDrawerFragment)
getSupportFragmentManager().findFragmentById(R.id.fragment_nav_drawer);
navigationDrawerFragment.setUp(R.id.fragment_nav_drawer, (DrawerLayout) findViewById(R.id.drawer_layout), toolbar);
mPager = (ViewPager) findViewById(R.id.pager);
adapter = new MyPagerAdapter(getSupportFragmentManager());
mPager.setAdapter(adapter);
mTabs = (SlidingTabLayout) findViewById(R.id.tabs);
mTabs.setDistributeEvenly(true);
mTabs.setCustomTabView(R.layout.custom_tab_view, R.id.tabText);
int bgColor = ContextCompat.getColor(this, R.color.colorPrimary);
mTabs.setBackgroundColor(bgColor);
mTabs.setSelectedIndicatorColors(ContextCompat.getColor(MainActivity.this, R.color.colorAccent));
mTabs.invalidate();
mTabs.setViewPager(mPager); …Run Code Online (Sandbox Code Playgroud) 我正在实现卡片视图,但我找不到任何边框选项来设置它的边框.
这是我的card.xml:
<android.support.v7.widget.CardView android:layout_marginTop="10dp"
android:id="@+id/cardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"
card_view:cardPreventCornerOverlap="false"
app:cardPreventCornerOverlap="false"
xmlns:card_view="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto">
<RelativeLayout
android:background="@drawable/tab_bg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title"
android:textSize="20sp" />
</RelativeLayout>
</android.support.v7.widget.CardView>
Run Code Online (Sandbox Code Playgroud)
这是我的图像,我想在卡片视图上实现绿色边框?
帮我.我怎么能实现这个呢?我没有线索.
谢谢.
我有一个像这样的3字符串:
"@Username: Deliverd your order",
"YOU got trophy: KING OF COINS",
"There is a package waiting for you to pick up from #surat to #mumbai",
Run Code Online (Sandbox Code Playgroud)
我想做的是通过点击事件获得不同颜色的用户名和城市名称.
能够实现的是通过分割为":"字符来获取用户名.但我不知道如何获得城市名称和点击两者的事件.
在城市名称中,只有最后一个城市颜色在变化,如何更改城市名称颜色并获取其点击事件.
这是我试过的:
if (notifications.getTitle().contains(":"))
{
String[] username = notifications.getTitle().split(":");
String uname = getColoredSpanned(username[0] + ":", "#ff7505");
String txt = getColoredSpanned(username[1], "#000000");
holder.txtTitle.append(Html.fromHtml(uname +" " + txt));
holder.txtTitle.setMovementMethod(LinkMovementMethod.getInstance());
}
else if (notifications.getTitle().contains("#"))
{
Matcher matcher =
Pattern.compile("#\\s(\\w+)").matcher(notifications.getTitle());
i=0;
while (matcher.find())
{
place.add(i, matcher.group(1));
i++;
}
String place1 = getColoredSpanned("#" + place.get(0), "#237BCD");
String place2 …Run Code Online (Sandbox Code Playgroud) 如何在React-native中的TextInput中实现@mention.
我已经尝试了这种反应本地提及但它不再维护了.有很多样式问题和回调问题.
我想要的是在textInput中显示这样的自定义视图.
点击列表后我想显示如下:
到目前为止,我能够实现:
当我在TextInput中键入'@'时,会出现用户列表.
当我点击用户时,我在TextInput中获得用户名
码
renderSuggestionsRow() {
return this.props.stackUsers.map((item, index) => {
return (
<TouchableOpacity key={`index-${index}`} onPress={() => this.onSuggestionTap(item.label)}>
<View style={styles.suggestionsRowContainer}>
<View style={styles.userIconBox}>
<Text style={styles.usernameInitials}>{!!item.label && item.label.substring(0, 2).toUpperCase()}</Text>
</View>
<View style={styles.userDetailsBox}>
<Text style={styles.displayNameText}>{item.label}</Text>
<Text style={styles.usernameText}>@{item.label}</Text>
</View>
</View>
</TouchableOpacity>
)
});
}
onSuggestionTap(username) {
this.setState({
comment: this.state.comment.slice(0, this.state.comment.indexOf('@')) + '#'+username,
active: false
});
}
handleChatText(value) {
if(value.includes('@')) {
if(value.match(/@/g).length > 0) {
this.setState({active: true});
}
} else {
this.setState({active: false});
}
this.setState({comment: value});
}
render() { …Run Code Online (Sandbox Code Playgroud) 我正在使用volly来完美地检索数据及其工作,除了我的json数组没有存储在缓存中.
这是我的代码:
private void getCacheValue() {
Cache cache = AppController.getInstance().getRequestQueue().getCache();
Cache.Entry entry = cache.get(Endpoints.product_url);
if(entry != null){
Log.w("Logdata:", ""+ entry.toString());
try {
String data = new String(entry.data, "UTF-8");
JSONArray jsonArray = new JSONArray(data);
// handle data, like converting it to xml, json, bitmap etc.,
Log.v("Hello", data);
listProduct.clear();
for (int i = 0; i < jsonArray.length(); i++) {
try {
JSONObject object = jsonArray.getJSONObject(i);
ItemCategories image = new ItemCategories();
image.setCategoryItem(object.getString(key_title));
image.setUrlThumb(object.getString(key_image));
listProduct.add(image);
} catch (JSONException e) {
Log.e(TAG, "Json parsing error: …Run Code Online (Sandbox Code Playgroud) 我在导航图中总共有12个片段..每个片段都有一个凌空方法.每个片段显示自己的凌空响应,除了position = 1和position = 5片段.
当我的应用程序启动
情形1: 我打开位置1片段,并且在打开位置5片段后,两个片段都具有位置1片段响应.
场景2:如果我打开位置5片段并且在打开位置1片段之后比两个片段都具有位置1片段响应.
场景1图像:
场景2图像:
我的片段事务方法类:
private void showFragment(Fragment fragment) {
llContainer = (LinearLayout)findViewById(R.id.container);
if (fragment != null) {
llContainer.removeAllViewsInLayout();
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.container, fragment, fragment.getClass().getName());
fragmentTransaction.commit();
fragmentManager.popBackStack();
}
}
@Override
public void onItemSelected(int position) {
Fragment frag = null;
switch (position) {
case POS_HOME:
frag = FragmentHome.instance(screenTitles[position]);
break;
case POS_INBOX:
txtToolbarTitle.setVisibility(View.VISIBLE);
txtToolbarTitle.setText("Notifications");
frag = FragmentInbox.instance(screenTitles[position]);
break;
case POS_LOG:
frag = FragmentLog.instance(screenTitles[position]);;
break;
case POS_BOOK:
frag = FragmentBook.instance(screenTitles[position]); …Run Code Online (Sandbox Code Playgroud) android android-fragments fragmenttransaction android-volley
现在我正在使用最新版本的appcompat和设计支持库.
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
Run Code Online (Sandbox Code Playgroud)
现在即将面临一些弃用
private void setupTabLayout() {
mTabLayout = (TabLayout)findViewById(R.id.tab_layout);
mAdapter = new MyPagerAdapter(getSupportFragmentManager());
mPager = (ViewPager)findViewById(R.id.pager);
mPager.setAdapter(mAdapter);
mTabLayout.setTabsFromPagerAdapter(mAdapter); <!-- deprecated -->
mTabLayout.setupWithViewPager(mPager);
}
Run Code Online (Sandbox Code Playgroud)
任何人都知道我要用什么代替..帮助我..谢谢
我添加对角线切割布局RecyclerView,但我没有得到预期的结果.我的第二个观点start with end of first view, and thats obvious.但我想要的是每个视图都是join with each-other这样的.
我的输出:
这就是我想要的:
CutLayout.class:
public class CutLayout extends FrameLayout {
private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
private Xfermode pdMode = new PorterDuffXfermode(PorterDuff.Mode.CLEAR);
private Path path = new Path();
public CutLayout(Context context) {
super(context);
}
public CutLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
public CutLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public CutLayout(Context context, AttributeSet attrs, int defStyleAttr, int …Run Code Online (Sandbox Code Playgroud) 当我将颜色设置为SlidingTabLayout对象时,我得到错误.这是我的mainActivity,首先我发现不推荐使用getResource.getColor ..所以我使用了contextCompat.getColor ..但现在它将变为null.
public class MainActivity extends AppCompatActivity {
private Toolbar toolbar;
private ViewPager mPager;
private SlidingTabLayout mTabs;
private MyPagerAdapter adapter;
Context context;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
toolbar = (Toolbar) findViewById(R.id.app_bar);
mPager = (ViewPager) findViewById(R.id.pager);
mTabs = (SlidingTabLayout) findViewById(R.id.tabs);
setSupportActionBar(toolbar);
assert getSupportActionBar() != null;
getSupportActionBar().setDisplayShowHomeEnabled(true);
NavigationDrawerFragment navigationDrawerFragment = (NavigationDrawerFragment)
getSupportFragmentManager().findFragmentById(R.id.fragment_nav_drawer);
navigationDrawerFragment.setUp(R.id.fragment_nav_drawer, (DrawerLayout) findViewById(R.id.drawer_layout), toolbar);
adapter = new MyPagerAdapter(getSupportFragmentManager(),MainActivity.this);
mPager.setAdapter(adapter);
mTabs.setViewPager(mPager);
mTabs.setDistributeEvenly(true);
int bgColor = ContextCompat.getColor(context,R.color.colorAccent);
mTabs.setBackgroundColor(bgColor);
mTabs.setSelectedIndicatorColors(ContextCompat.getColor(context, R.color.colorAccent));
mTabs.invalidate();
mTabs.setCustomTabView(R.layout.custom_tab_view,R.id.tabText);
}
@Deprecated
public boolean onCreateOptionsMenu(Menu menu) …Run Code Online (Sandbox Code Playgroud) 版本:
"native-base": "^2.4.2",
"react": "16.3.1",
"react-native": "0.55.2",
"react-native-global-font": "^1.0.1",
"react-native-router-flux": "^4.0.0-beta.28",
"react-navigation": "^1.5.11"
Run Code Online (Sandbox Code Playgroud)
当我添加反应导航时,我无法更改状态栏颜色,我的状态栏变为蓝色。
这是我的Navigationview.js代码
render() {
return (
<Root style={styles.container}>
<StatusBar
backgroundColor="white"
barStyle="dark-content"
/>
<MainView />
</Root>
);
}
const drawerHeader = (props) => (
<Container style={styles.container}>
<Header style={styles.header}>
<Body style={styles.body}>
<Icon name="person" style={{ fontSize: 40, color: '#CCCCCC' }} />
</Body>
</Header>
<Content>
<SafeAreaView forceInset={{ top: 'always', horizontal: 'never' }}>
<DrawerItems {...props} />
<Button title="Logout" onPress={() => Actions.reset('login')} />
</SafeAreaView>
</Content>
</Container>
);
const MainView = DrawerNavigator({
DASHBOARD: { …Run Code Online (Sandbox Code Playgroud) android android-statusbar react-native native-base react-navigation
android ×9
react-native ×2
java ×1
mention ×1
native-base ×1
regex ×1
split ×1
string ×1
textinput ×1