我试过在我的应用程序中使用BottomNavigationView.
当我单击图标片段时,正确显示片段,但图标在选择时不会更改其颜色,第一个片段的图标保持彩色.它看起来像我选择的任何片段
我做错了什么或者所选片段的图标颜色是单独调整的吗?
我的MainActivity:
public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
private Toolbar toolbar;
public static FloatingActionButton addDeadline;
BottomNavigationView bottomNavigationView;
FrameLayout frameLayout;
private HomeFragment homeFragment;
private RecyclerViewFragment recyclerViewFragment;
private HistoryFragment historyFragment;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_drawer);
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);// language configuration
String lang = getResources().getConfiguration().locale.getDisplayLanguage(Locale.CHINESE);
Locale locale = new Locale(lang);
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
getBaseContext().getResources().updateConfiguration(config, null);
toolbar = findViewById(R.id.toolbar_main);
setSupportActionBar(toolbar);
homeFragment = new HomeFragment();
recyclerViewFragment = new …Run Code Online (Sandbox Code Playgroud) 我正在尝试将GCDAsyncSocket实现到 mac os x (Mojave 10.14.3) 应用程序以侦听来自 localhost:port 的数据。
问题是无论我选择哪个端口我总是会收到此错误:
Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"
UserInfo={NSLocalizedDescription=Operation not permitted,
NSLocalizedFailureReason=Error in bind() function}
Run Code Online (Sandbox Code Playgroud)
我已经尝试过这个,但没有成功。
这是我在AppDelegate.mm中的实现:
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
listenSocket = [[GCDAsyncSocket alloc] initWithDelegate:(id<GCDAsyncSocketDelegate>) self delegateQueue:dispatch_get_main_queue()];
connectedSockets = [[NSMutableArray alloc] initWithCapacity:1];
isRunning = NO;
NSError *err = nil;
if (![listenSocket connectToHost:@"localhost" onPort:12345 error:&err]){
NSLog(@"I goofed: %@", err);
}
}
-(void)getData{
if(!isRunning)
{
int port = 12345;
if(port < 0 || port > 65535)
{
port …Run Code Online (Sandbox Code Playgroud)