当我制作Android设计时,它给我的间距,就像我们说在网上填充我如何使它100%宽度.

这是我的布局代码
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitXY"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.mobilink.mobilink.MainActivity">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:weightSum="1">
<LinearLayout
android:background="#ff00cc70"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.25"></LinearLayout>
<LinearLayout
android:background="#ff0087cc"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.20"></LinearLayout>
<LinearLayout
android:background="#ffff1a27"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.20"></LinearLayout>
<LinearLayout
android:background="#ff3444ff"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.20"></LinearLayout>
<LinearLayout
android:background="#ff0019ff"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.20"></LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
您好我的代码有问题.我想在后台播放音乐,这将与IntentServiceAndroid一起运行.但是如果我实现这条线,我的SDk会给我一个错误.
Radio.java
public class Radio extends Activity implements OnCompletionListener,
OnPreparedListener, OnErrorListener, OnBufferingUpdateListener, MusicFocusable, ViewFactory {
Run Code Online (Sandbox Code Playgroud)
....
play.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View btn) {
if (!playState) {
play.setImageResource(R.drawable.stop);
handler.postDelayed(handlePlayRequest, 300);
startService(new Intent(this, MyService.class));
"Here is Error 1"
}
else {
play.setImageResource(R.drawable.play);
status.setText("Drücke Play!");
handler.postDelayed(handlePlayRequest, 300);
stopService(new Intent(this, MyService.class));
"Here is Error 2"
}
}
Run Code Online (Sandbox Code Playgroud)
和
MyService.java
import android.app.Service;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.IBinder;
import android.util.Log;
import android.widget.Toast;
public class MyService extends Service {
private static final …Run Code Online (Sandbox Code Playgroud) 我AppCompat在教会应用程序中使用库,但我的菜单图标没有出现ActionBar.
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// toggle nav drawer on selecting action bar app icon/title
if (mDrawerToggle.onOptionsItemSelected(item)) {
return true;
}
// Handle action bar actions click
switch (item.getItemId()) {
case R.id.action_settings:
return true;
case R.id.menu_item_share:
shareApp();
return true;
case R.id.menu_item_about:
Intent intentAbout = new Intent(MainActivity.this, AboutActivity.class);
startActivity(intentAbout);
return …Run Code Online (Sandbox Code Playgroud) 如下所示创建一个数组作为列表项的no我假设你有五个项目:
int[] color_arr={Color.BLUE,Color.CYAN,Color.YELLOW,Color.GREEN,Color.RED};
Run Code Online (Sandbox Code Playgroud)
并在getView()自定义适配器的方法中使用它如下: -
public View getView(int position, View convertView, ViewGroup parent)
{
LayoutInflater inflater = getLayoutInflater();
View row=convertView;
row = inflater.inflate(R.layout.listview_custome, parent, false);
row.setBackgroundColor(color_arr[position]);// this set background color
TextView textview = (TextView) row.findViewById(R.id.tv_list);
ImageView imageview = (ImageView) row.findViewById(R.id.iv_list);
textview.setText(data_text[position]);
imageview.setImageResource(data_image[position]);
return (row);
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,如果列表项中有超过5个项目,listview中每行可能有5种不同的颜色吗?