我在我的跨平台应用程序中使用System.Net.Sockets
作为TCP/IP Client
。我有SharedProject,我有班负责连接/接收数据。我可以在Android
中运行应用,但我发现System.Net.Sockets
中Windows Phone 8.1
不可用。我看到要使用Windows Phone
我可以使用Windows.Networking.Sockets
,但是当我在sing Windows.Networking.Sockets
的课程中添加你Shared Project
时,我会收到错误:
无法找到类型或命名空间名称“Windows”
我的问题是如何将System.Net.Sockets
或Windows.Networking.Sockets
与Windows Phone 8.1
一起使用?
答案 0 :(得分:1)
根据此previous question,您需要将public class MainActivity extends AppCompatActivity {
private ImageView mImageView;
private Button mButton;
private ImageButton mButton2;
private Button mButton3;
private Button mButton4;
private Button mButton5;
private Button mButton6;
private CirclePageIndicator indicator;
private CirclePageIndicator indicator2;
private CirclePageIndicator indicator3;
private CirclePageIndicator indicator4;
private static ViewPager mPager;
private static ViewPager mPager2;
private static ViewPager mPager3;
private static ViewPager mPager4;
private static int currentPage = 0;
private static int currentPage2 = 0;
private static int currentPage3 = 0;
private static int currentPage4 = 0;
private static int NUM_PAGES = 0;
ExpandableListAdapter listAdapter;
ExpandableListAdapter listAdapter2;
ExpandableListAdapter listAdapter3;
ExpandableListAdapter listAdapter4;
ExpandableListAdapter listAdapter5;
List<String> listDataHeader2;
HashMap<String, List<String>> listDataChild2;
List<String> listDataHeader3;
HashMap<String, List<String>> listDataChild3;
List<String> listDataHeader4;
HashMap<String, List<String>> listDataChild4;
List<String> listDataHeader5;
HashMap<String, List<String>> listDataChild5;
ExpandableListView expListView;
ExpandableListView expListView2;
ExpandableListView expListView3;
ExpandableListView expListView4;
ExpandableListView expListView5;
ExpandableListView expListView6;
List<String> listDataHeader;
HashMap<String, List<String>> listDataChild;
private static final Integer[] IMAGES = {R.drawable.one_full, R.drawable.two_full, R.drawable.three_full, R.drawable.four_full, R.drawable.five_full, R.drawable.six_full, R.drawable.seven_full};
private ArrayList<Integer> ImagesArray = new ArrayList<Integer>();
private static final Integer[] IMAGES2 = {R.drawable.bir_bir, R.drawable.bir_iki, R.drawable.bir_uc};
private ArrayList<Integer> ImagesArray2 = new ArrayList<Integer>();
private static final Integer[] IMAGES3 = {R.drawable.iki_bir, R.drawable.iki_iki, R.drawable.iki_uc};
private ArrayList<Integer> ImagesArray3 = new ArrayList<Integer>();
private static final Integer[] IMAGES4 = {R.drawable.uc_bir, R.drawable.uc_iki, R.drawable.uc_uc};
private ArrayList<Integer> ImagesArray4 = new ArrayList<Integer>();
String[] items = {"diğer","iletişim", "sss", "online işlem merkezi"};
String[] items2 = {"İnternet","Sonet ADSL","Sonet Fiber", "Sonet Yalın İnternet", "Sonet Uydu İnternet"};
String[] items3 = {"Cihazlar","Modem"};
String[] items4 = {"Kampanyalar","Sonet ADSL", "Sonet Fiber", "Sonet Yalın İnternet","Sonet Uydu İnternet"};
String[] items5 = {"Destek","Fatura İşlemleri", "Satış Noktaları", "Bize Ulaşın","Sosyal Medya Sonet","Bölge Çözüm Ortaklığı"};
String[] items6 = {"diğer","iletişim", "sss", "online işlem merkezi"};
String[] items7 = {"diğer","iletişim", "sss", "online işlem merkezi"};
String[] items8 = {"diğer","iletişim", "sss", "online işlem merkezi"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
init();
}
private void init() {
mImageView = (ImageView) findViewById(R.id.imageview);
mImageView.setBackgroundColor(Color.rgb(0, 0, 205));
mButton = (Button) findViewById(R.id.cihazlar);
mButton.setBackgroundColor(Color.rgb(25, 25, 112));
mButton2 = (ImageButton) findViewById(R.id.image_button);
mButton2.setBackgroundColor(Color.rgb(25, 25, 112));
mButton3 = (Button) findViewById(R.id.internet);
mButton3.setBackgroundColor(Color.rgb(25, 25, 112));
mButton4 = (Button) findViewById(R.id.servisler);
mButton4.setBackgroundColor(Color.rgb(25, 25, 112));
mButton5 = (Button) findViewById(R.id.kampanya);
mButton5.setBackgroundColor(Color.rgb(25, 25, 112));
mButton6= (Button)findViewById(R.id.button1);
mButton6.setBackgroundColor(Color.rgb(25,25,112));
mButton6.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
PopupMenu popup = new PopupMenu(MainActivity.this, mButton6);
//Inflating the Popup using xml file
popup.getMenuInflater().inflate(R.menu.popup_menu, popup.getMenu());
//registering popup with OnMenuItemClickListener
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
Toast.makeText(MainActivity.this, "You Clicked : " + item.getTitle(), Toast.LENGTH_SHORT).show();
return true;
}
});
popup.show();//showing popup menu
}
});
mButton.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
Intent i=new Intent(MainActivity.this,Cihazlar.class);
startActivity(i);
}
});
mButton2.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
Intent i=new Intent(MainActivity.this,MainActivity.class);
startActivity(i);
}
});
mButton3.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
Intent i=new Intent(MainActivity.this,Internet.class);
startActivity(i);
}
});
mButton4.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
Intent i=new Intent(MainActivity.this,Servisler.class);
startActivity(i);
}
});
mButton5.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
Intent i=new Intent(MainActivity.this,Kampanya.class);
startActivity(i);
}
});
for (int i = 0; i < IMAGES.length; i++)
ImagesArray.add(IMAGES[i]);
mPager = (ViewPager) findViewById(R.id.pager);
mPager.setAdapter(new SlidingImage_Adapter(MainActivity.this, ImagesArray));
for (int i = 0; i < IMAGES2.length; i++)
ImagesArray2.add(IMAGES2[i]);
mPager2 = (ViewPager) findViewById(R.id.pager2);
mPager2.setAdapter(new SlidingImage_Adapter(MainActivity.this, ImagesArray2));
for (int i = 0; i < IMAGES3.length; i++)
ImagesArray3.add(IMAGES3[i]);
mPager3 = (ViewPager) findViewById(R.id.pager3);
mPager3.setAdapter(new SlidingImage_Adapter(MainActivity.this, ImagesArray3));
for (int i = 0; i < IMAGES4.length; i++)
ImagesArray4.add(IMAGES4[i]);
mPager4 = (ViewPager) findViewById(R.id.pager4);
mPager4.setAdapter(new SlidingImage_Adapter(MainActivity.this, ImagesArray4));
indicator = (CirclePageIndicator) findViewById(R.id.indicator);
indicator.setViewPager(mPager);
indicator2 = (CirclePageIndicator) findViewById(R.id.indicator2);
indicator2.setViewPager(mPager2);
indicator3 = (CirclePageIndicator) findViewById(R.id.indicator3);
indicator3.setViewPager(mPager3);
indicator4 = (CirclePageIndicator) findViewById(R.id.indicator4);
indicator4.setViewPager(mPager4);
final float density = getResources().getDisplayMetrics().density;
indicator.setRadius(3 * density);
NUM_PAGES = IMAGES.length;
// Auto start of viewpager
final Handler handler = new Handler();
final Runnable Update = new Runnable() {
public void run() {
if (currentPage == NUM_PAGES) {
currentPage = 0;
}
mPager.setCurrentItem(currentPage++, true);
if (currentPage2 == NUM_PAGES) {
currentPage2 = 0;
}
mPager2.setCurrentItem(currentPage2++, true);
if (currentPage3 == NUM_PAGES) {
currentPage3 = 0;
}
mPager3.setCurrentItem(currentPage3++, true);
if (currentPage4 == NUM_PAGES) {
currentPage4 = 0;
}
mPager4.setCurrentItem(currentPage4++, true);
}
};
Timer swipeTimer = new Timer();
swipeTimer.schedule(new TimerTask() {
@Override
public void run() {
handler.post(Update);
}
}, 3000, 3000);
// Pager listener over indicator
indicator.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageSelected(int position) {
currentPage = position;
}
@Override
public void onPageScrolled(int pos, float arg1, int arg2) {
}
@Override
public void onPageScrollStateChanged(int pos) {
}
});
indicator2.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageSelected(int position) {
currentPage2 = position;
}
@Override
public void onPageScrolled(int pos, float arg1, int arg2) {
}
@Override
public void onPageScrollStateChanged(int pos) {
}
});
indicator3.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageSelected(int position) {
currentPage3 = position;
}
@Override
public void onPageScrolled(int pos, float arg1, int arg2) {
}
@Override
public void onPageScrollStateChanged(int pos) {
}
});
indicator4.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageSelected(int position) {
currentPage4 = position;
}
@Override
public void onPageScrolled(int pos, float arg1, int arg2) {
}
@Override
public void onPageScrollStateChanged(int pos) {
}
});
expListView = (ExpandableListView) findViewById(R.id.lvExp);
expListView2 = (ExpandableListView) findViewById(R.id.lvExp2);
expListView3 = (ExpandableListView) findViewById(R.id.lvExp3);
expListView4 = (ExpandableListView) findViewById(R.id.lvExp4);
expListView5 = (ExpandableListView) findViewById(R.id.lvExp5);
// preparing list data
prepareListData();
listAdapter = new ExpandableListAdapter(this, listDataHeader, listDataChild);
listAdapter2 = new ExpandableListAdapter(this, listDataHeader2, listDataChild2);
listAdapter3 = new ExpandableListAdapter(this, listDataHeader3, listDataChild3);
listAdapter4 = new ExpandableListAdapter(this, listDataHeader4, listDataChild4);
listAdapter5 = new ExpandableListAdapter(this, listDataHeader5, listDataChild5);
// setting list adapter
expListView.setAdapter(listAdapter);
expListView2.setAdapter(listAdapter3);
expListView3.setAdapter(listAdapter4);
expListView4.setAdapter(listAdapter5);
expListView5.setAdapter(listAdapter2);
expListView5.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
@Override
public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
if (groupPosition == 4) {
Intent i = new Intent(getApplicationContext(), Internet.class);
startActivity(i);
}
if (groupPosition == 7) {
Intent i = new Intent(getApplicationContext(), subelerimiz.class);
startActivity(i);
}
return false;
}
});
expListView5.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
if (groupPosition == 0) {
if (childPosition == 0) {
Intent i = new Intent(getApplicationContext(), internet_sonet_adsl.class);
startActivity(i);
}
if (childPosition == 1) {
Intent i = new Intent(getApplicationContext(), internet_sonet_fiber.class);
startActivity(i);
}
if (childPosition == 2) {
Intent i = new Intent(getApplicationContext(), internet_sonet_yalin_internet.class);
startActivity(i);
}
if (childPosition == 3) {
Intent i = new Intent(getApplicationContext(), internet_sonet_uydu_internet.class);
startActivity(i);
}
if (childPosition == 4) {
Intent i = new Intent(getApplicationContext(), internet_tum_paketler.class);
startActivity(i);
}
if (childPosition == 5) {
Intent i = new Intent(getApplicationContext(), internet_hizmet_karsilastirma.class);
startActivity(i);
}
if (childPosition == 6) {
Intent i = new Intent(getApplicationContext(), sikca_sorulan_sorular.class);
startActivity(i);
}
if (childPosition == 7) {
Intent i = new Intent(getApplicationContext(), internet_diger_internet_hizmetleri.class);
startActivity(i);
}
if (childPosition == 8) {
Intent i = new Intent(getApplicationContext(), internet_paket_sihirbazi.class);
startActivity(i);
}
}
if (groupPosition == 1) {
if (childPosition == 0) {
Intent i = new Intent(getApplicationContext(), servisler_guvenlik.class);
startActivity(i);
}
if (childPosition == 1) {
Intent i = new Intent(getApplicationContext(), servisler_bulut_bilisim.class);
startActivity(i);
}
if (childPosition == 2) {
Intent i = new Intent(getApplicationContext(), Internet.class);
startActivity(i);
}
if (childPosition == 3) {
Intent i = new Intent(getApplicationContext(), servisler_mobil_servisler.class);
startActivity(i);
}
if (childPosition == 4) {
Intent i = new Intent(getApplicationContext(), servisler_sonet_teknoloji.class);
startActivity(i);
}
}
if (groupPosition == 2) {
if (childPosition == 0) {
Intent i = new Intent(getApplicationContext(), kampanya_sonet_adsl.class);
startActivity(i);
}
if (childPosition == 1) {
Intent i = new Intent(getApplicationContext(), kampanya_sonet_airfiber.class);
startActivity(i);
}
if (childPosition == 2) {
Intent i = new Intent(getApplicationContext(), kampanya_sonet_fiber.class);
startActivity(i);
}
if (childPosition == 3) {
Intent i = new Intent(getApplicationContext(), kampanya_sonet_yalin_internet.class);
startActivity(i);
}
if (childPosition == 4) {
Intent i = new Intent(getApplicationContext(), kampanya_sonet_uydu_internet.class);
startActivity(i);
}
if (childPosition == 5) {
Intent i = new Intent(getApplicationContext(), kampanya_tablet_hediye.class);
startActivity(i);
}
}
if (groupPosition == 3) {
if (childPosition == 0) {
Intent i = new Intent(getApplicationContext(), senindunyan_guvenli_evim.class);
startActivity(i);
}
if (childPosition == 1) {
Intent i = new Intent(getApplicationContext(), senindunyan_guvenli_isim.class);
startActivity(i);
}
if (childPosition == 2) {
Intent i = new Intent(getApplicationContext(), senindunyan_akilli_evim.class);
startActivity(i);
}
if (childPosition == 3) {
Intent i = new Intent(getApplicationContext(), senindunyan_akilli_isim.class);
startActivity(i);
}
if (childPosition == 4) {
Intent i = new Intent(getApplicationContext(), senindunyan_sonet_akilli_tv.class);
startActivity(i);
}
if (childPosition == 5) {
Intent i = new Intent(getApplicationContext(), sikca_sorulan_sorular.class);
startActivity(i);
}
}
if (groupPosition == 5) {
if (childPosition == 0) {
Intent i = new Intent(getApplicationContext(), sikca_sorulan_sorular.class);
startActivity(i);
}
if (childPosition == 1) {
Intent i = new Intent(getApplicationContext(), cihazlar_sonet_musterilerine_ozel.class);
startActivity(i);
}
}
if (groupPosition == 6) {
if (childPosition == 0) {
Intent i = new Intent(getApplicationContext(), destek_fatura_islemleri.class);
startActivity(i);
}
if (childPosition == 1) {
Intent i = new Intent(getApplicationContext(), destek_satis_noktalari.class);
startActivity(i);
}
if (childPosition == 2) {
Intent i = new Intent(getApplicationContext(), destek_bize_ulasin.class);
startActivity(i);
}
if (childPosition == 3) {
Intent i = new Intent(getApplicationContext(), TV.class);
startActivity(i);
}
if (childPosition == 4) {
Intent i = new Intent(getApplicationContext(), destek_iletisim.class);
startActivity(i);
}
if (childPosition == 5) {
Intent i = new Intent(getApplicationContext(), destek_sosyal_medya_sonet.class);
startActivity(i);
}
if (childPosition == 6) {
Intent i = new Intent(getApplicationContext(), destek_bolge_cozum_ortakligi.class);
startActivity(i);
}
if (childPosition == 7) {
Intent i = new Intent(getApplicationContext(), sikca_sorulan_sorular.class);
startActivity(i);
}
if (childPosition == 8) {
Intent i = new Intent(getApplicationContext(), online_islem_merkezi.class);
startActivity(i);
}
}
return false;
}
});
expListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
if (groupPosition == 0) {
if (childPosition == 0) {
Intent i = new Intent(getApplicationContext(), internet_sonet_adsl.class);
startActivity(i);
}
if (childPosition == 1) {
Intent i = new Intent(getApplicationContext(), internet_sonet_fiber.class);
startActivity(i);
}
if (childPosition == 2) {
Intent i = new Intent(getApplicationContext(), internet_sonet_yalin_internet.class);
startActivity(i);
}
if (childPosition == 3) {
Intent i = new Intent(getApplicationContext(), internet_sonet_uydu_internet.class);
startActivity(i);
}
if (childPosition == 4) {
Intent i = new Intent(getApplicationContext(), internet_tum_paketler.class);
startActivity(i);
}
if (childPosition == 5) {
Intent i = new Intent(getApplicationContext(), internet_hizmet_karsilastirma.class);
startActivity(i);
}
if (childPosition == 6) {
Intent i = new Intent(getApplicationContext(), sikca_sorulan_sorular.class);
startActivity(i);
}
if (childPosition == 7) {
Intent i = new Intent(getApplicationContext(), internet_diger_internet_hizmetleri.class);
startActivity(i);
}
if (childPosition == 8) {
Intent i = new Intent(getApplicationContext(), internet_paket_sihirbazi.class);
startActivity(i);
}
}
return false;
}
});
expListView2.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
if (groupPosition == 0) {
if (childPosition == 0) {
Intent i = new Intent(getApplicationContext(), servisler_guvenlik.class);
startActivity(i);
}
if (childPosition == 1) {
Intent i = new Intent(getApplicationContext(), servisler_bulut_bilisim.class);
startActivity(i);
}
if (childPosition == 2) {
Intent i = new Intent(getApplicationContext(), Internet.class);
startActivity(i);
}
if (childPosition == 3) {
Intent i = new Intent(getApplicationContext(), servisler_mobil_servisler.class);
startActivity(i);
}
if (childPosition == 4) {
Intent i = new Intent(getApplicationContext(), servisler_sonet_teknoloji.class);
startActivity(i);
}
}
return false;
}
});
expListView3.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
if (groupPosition == 0) {
if (childPosition == 0) {
Intent i = new Intent(getApplicationContext(), sikca_sorulan_sorular.class);
startActivity(i);
}
if (childPosition == 1) {
Intent i = new Intent(getApplicationContext(), cihazlar_sonet_musterilerine_ozel.class);
startActivity(i);
}
}
return false;
}
});
expListView4.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
if (groupPosition == 0) {
if (childPosition == 0) {
Intent i = new Intent(getApplicationContext(), Senindunyan.class);
startActivity(i);
}
if (childPosition == 1) {
Intent i = new Intent(getApplicationContext(), cihazlar_sonet_musterilerine_ozel.class);
startActivity(i);
}
if (childPosition == 2) {
Intent i = new Intent(getApplicationContext(), Destek.class);
startActivity(i);
}
}
return false;
}
});
// To make ExpandableListView scrollable in the ScrollView
expListView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
// Disallow ScrollView to intercept touch events.
v.getParent().requestDisallowInterceptTouchEvent(true);
break;
case MotionEvent.ACTION_UP:
// Allow ScrollView to intercept touch events.
v.getParent().requestDisallowInterceptTouchEvent(false);
break;
}
// Handle ListView touch events.
v.onTouchEvent(event);
return true;
}
});
// To make ExpandableListView scrollable in the ScrollView
expListView2.setOnTouchListener(new View.OnTouchListener() {
@Override
}
添加到项目中才能使用System.Dll
。
或者你也可以尝试这个Sockets Plugin for Xamarin
答案 1 :(得分:1)
好的我通过输入共享类库解决了我的问题,接下来我双击.NET,然后从左侧选择Windows并单击搜索栏附近的“在解决方案资源管理器中选择项目中添加引用”按钮。 / p>